Python Set pop() Method
Example
Remove a random item from the set:
fruits = {"apple", "banana", "cherry"}
fruits.pop()
print(fruits)
Try it Yourself »
Definition and Usage
The pop()
method removes a random item from
the set.
This method returns the removed item.
Syntax
set.pop()
Parameter Values
No parameter values.
More Examples
Example
Return the removed element:
fruits = {"apple", "banana", "cherry"}
x = fruits.pop()
print(x)
Try it Yourself »
Note: The pop()
method
returns removed value.