Menu Close

Python Set pop() Method

Python set pop

In this set method tutorial, we are going to learn how to use the set pop() method to remove items from the set.
Click here to learn all about sets in Python, before going through this tutorial.

Python Set pop() Method

Python set pop() method is used to removes the random item from the set and return the deleted item.The set pop function actually works with only sets in Python because it is a set method.


Syntax of pop function in python is:-



The python set pop method does not take any parameter.

Return Value

set pop function in python returns only removed value.

Python set pop example

In this we will randomly remove item from the set using set pop function.


set1 = {'Python', 'Java', 'JavaScript', 'C++'}
result = set1.pop()


{'Java', 'Python', 'C++'}


In this article, you have seen how to use the python set pop method to removes the random items from the set. This method removes only deleted items. I f you like this article, please share, support and keep visit for further Python tutorials.

Other set methods

For More Information:- Click Here

Thanks for reading…

Python Set union() Method
Python Set add() Method

Related Posts