How to iterate throuhg dictionary
François Pinard
pinard at iro.umontreal.ca
Wed Aug 8 10:06:27 EDT 2001
> Piotr Legiecki wrote:
> > I'v created dictionary named d={}. Its structure is like this: {key,
> > [list]} I'd like to print all values stored in 'd'. What is the easiest
> > way to do it?
[Mark Robinson]
> you might try something like:
> for key in d.keys():
> print 'key:'
> for value in d[key]:
> print value
It is often nice to do:
import pprint
pprint.pprint(d)
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list