[Tutor] Dictionaries

Jon Moore jonathan.r.moore at gmail.com
Thu Jan 26 00:23:06 CET 2006


Hi

Is there anyway to print informtation from dictionaries better than this?:

>>> pairs = {"Jon Moore": "Tony Moore",
         "Simon Nightingale": "John Nightingale",
         "David Willett": "Bernard Willet",
         "John Jackson": "Stuart Jackson",
         "James Southey": "Richard Southey",
         "William Forsythe": "Shaun Forsythe"}
>>> print pairs.keys()
['David Willett', 'Jon Moore', 'John Jackson', 'Simon Nightingale', 'James
Southey', 'William Forsythe']
>>>

Is there no way to make it a nice list as I want to print the keys and
values next to each other in a list such as:

Jon Moore                  Tony Moore
Simon Nightingale       John Nightingale
David Willett               Bernard Willet
John Jackson             Stuart Jackson
James Southey          Richard Southey
William Forsythe        Shaun Forsythe

For anyone who is wondering, it is to show father/son pairs. Next is to add
grandfathers *eek*.
--
Best Regards

Jon Moore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060125/3faa6605/attachment.html 


More information about the Tutor mailing list