Many websites claim that the pop()
method removes a random element from the set.
I'm confused because popping an element seems to be a deterministic process:
>>> {1,2,3,4,5}.pop()
1
>>> {1,2,3,4,5}.pop()
1
>>> {1,2,3,4,5}.pop()
1
This behaviour seems to be independent of the set contents
>>> {'a', type(2), (1)}.pop()
<class 'int'>
>>> {'a', type(2), (1)}.pop()
<class 'int'>
>>> {'a', type(2), (1)}.pop()
<class 'int'>
Why is this the case? How does pop()
internally work? Is it incorrect to say that the pop()
method is random?