bug in tutorial 7.Input and Output
![](https://secure.gravatar.com/avatar/f10145d9f5fec874b3bf33c89212458f.jpg?s=120&d=mm&r=g)
page : http://docs.python.org/tutorial/inputoutput.html explanation :
table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}>>> for name, phone in table.items():... print '{0:10} ==> {1:10d}'.format(name, phone)...Jack ==> 4098Dcab ==> 7678Sjoerd ==> 4127
Above result should be the following. I believe 'table' is dictionary and it's sorting the items based on key values. Dcab -> 7678 Jack -> 4098 Sjoerd -> 4127 Regards.
![](https://secure.gravatar.com/avatar/3c46e59585526b90c088845402bc8407.jpg?s=120&d=mm&r=g)
On 28.06.2012 15:40, 장동헌(DongHeon Jang) wrote:
page : http://docs.python.org/tutorial/inputoutput.html explanation :
table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678} for name, phone in table.items(): ... print '{0:10} ==> {1:10d}'.format(name, phone) ... Jack ==> 4098 Dcab ==> 7678 Sjoerd ==> 4127
Above result should be the following. I believe 'table' is dictionary and it's sorting the items based on key values.
Dcab -> 7678 Jack -> 4098 Sjoerd -> 4127
Hi DongHeon, a dictionary is not sorted, and when you retrieve the items using items() or iteritems(), they can appear in any order, depending on your system. cheers, Georg
participants (2)
-
Georg Brandl
-
장동헌(DongHeon Jang)