0

According to Python documentation the pop() method removes and returns an arbitrary element from the set.

In my example, I have two sets myset1 and myset2. Now when I call pop() method on both myset1 and myset2, pop() method always removes and returns the first element of both sets. So why does the documetation say: pop() method removes and returns an arbitrary element from the set? Because in my example the pop() method always removes and returns the first /same element of sets.

myset1={i for i in range(99)}
myset2={i for i in range(99)}

for  i in range(99):
  myset1.pop()
  print(myset1)
  myset2.pop()
  print(myset2)
N Randhawa
  • 8,773
  • 3
  • 43
  • 47

0 Answers0