Python: .pop() On Unordered Sets
I have a question regarding the .pop() method. In the documentation, it states that on sets: Remove and return an arbitrary element from the set. So what exactly does 'arbitrary'
Solution 1:
No.
"Arbitrary" means the implementation returns whichever element is most convenient. You are not guaranteed randomness. Use random.sample()
or random.shuffle()
if you need random selection.
Post a Comment for "Python: .pop() On Unordered Sets"