How to iterate throuhg dictionary
Mark Robinson
m.1.robinson at herts.ac.uk
Wed Aug 8 10:07:55 EDT 2001
I just had a quick play with that, and I can't see any difference
between your example verbatum and simply print d. How does pprint work
and (I assume it stands for pretty print or something) how should it look?
cheers
blobby
François Pinard wrote:
>> 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)
>
More information about the Python-list
mailing list