Reversing a dict?
Jeremy Sanders
jeremy+complangpython at jeremysanders.net
Tue May 6 11:26:06 EDT 2008
krumblebunk at gmail.com wrote:
> Hi - further to my earlier query regarding partial matches (which with
> all your replies enabled me to advance my understanding, thanks), I
> now need to reverse a dict.
There is no guaranteed order to the items stored in a dictionary. They can
and will move around as the dict is modified. Have a look at
diveintopython:
http://www.diveintopython.org/getting_to_know_python/dictionaries.html
You'll have to store your keys in a list or tuple to keep them ordered.
Jeremy
--
Jeremy Sanders
http://www.jeremysanders.net/
More information about the Python-list
mailing list