dictionary: keys() and values()

Irmen de Jong irmen at NOSPAMREMOVETHISxs4all.nl
Fri Jun 14 00:00:42 CEST 2002

Andrew Koenig wrote:
> From the library reference, 2.2.7, footnote 3:
> If keys() and values() are called with no intervening modifications to the
> dictionary, the two lists will directly correspond.  This allows the creation
> of (value, key) pairs using zip():  "pairs = zip(a.values(), a.keys())".

Why would you want to do that if you have .items()?


More information about the Python-list mailing list