[Tutor] Dictionaries

Alan Gauld alan.gauld at freenet.co.uk
Thu Jan 26 14:43:22 CET 2006

> How would I modify this to just print either the values or keys?

Just ask for the values or the keys!

for value in pairs.values()
     print value

for key in pairs.keys()
     print key

for key,value in pairs.items()
    print key
    print value

Dictionaries are extremely powerful data containers.


Alan G
Author of the learn to program web tutor

More information about the Tutor mailing list