choosing a random element from a dictionary

Yuval yuvalfeld at hotmail.com
Wed Feb 5 19:30:27 EST 2003


Is there a function that picks a random element from a dictionary? To
my understanding the popitem() method does that, but it also removes
it from the dictionary. Of course I can use popitem() and add it back
directly, but is there any other way of doing so?

Thanks.




More information about the Python-list mailing list