Iterating over the data items in a dict.
Moshe Zadka
py-list at zadka.site.co.il
Tue Nov 7 08:49:20 EST 2000
>
> I would like to iterate over the data items, not the keys, in a dict.
> The closest I can get is:
>
> for n in mydict.keys():
> i = mydict[n]
> do_something_useful(i)
>
> However, this seems a bit awkward.
See the .values() and .items() methods in the documentation.
--
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus.
Please stop the spread of signature viruses!
More information about the Python-list
mailing list