lopping over Dictionaries
Mike Steed
MSteed at altiris.com
Fri Sep 17 14:37:06 EDT 1999
> From: Kevin Howe [mailto:khowe at performance-net.com]
> Sent: Friday, September 17, 1999 12:07 PM
> To: python-list at python.org
> Subject: lopping over Dictionaries
>
> Is it possible to iterate through list of keys in a Dictionary?
>
> something like this:
>
> tel = {'jack': 4098, 'sape': 4139}
>
> for (name, value) in tel.keys:
> print name, value
Wow, you got it almost perfect. :-)
tel = {'jack': 4098, 'sape': 4139}
for (name, value) in tel.items():
print name, value
See http://www.python.org/doc/current/lib/typesmapping.html for more
dictionary methods.
M.
More information about the Python-list
mailing list