Python Set pop() Method
Example
Delete a random item from the set:
fruits = {"apple", "banana", "cherry"} fruits.pop() print(fruits)
Definition and Usage
The pop() method deletes a random item from the set.
This method returns the deleted item.
Syntax
set.pop()
Parameter value
No parameter value.
More Examples
Example
Return the deleted element:
fruits = {"apple", "banana", "cherry"} x = fruits.pop() print(x)
Note: The pop() method returns the deleted value.