[docs] bug in tutorial 7.Input and Output

Georg Brandl georg at python.org
Sun Jul 1 09:51:52 CEST 2012


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



More information about the docs mailing list