Dictionary Keys question

FireNWater khoard at gmail.com
Wed Jan 30 17:47:36 EST 2008


I'm curious why the different outputs of this code.  If I make the
dictionary with letters as the keys, they are not listed in the
dictionary in alphabetical order, but if I use the integers then the
keys are in numerical order.

I know that the order of the keys is not important in a dictionary,
but I was just curious about what causes the differences.  Thanks!!

list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
list2 = [1,2,3,4,5,6,7,8]

Dictionary = dict(zip(list1, list2))
print Dictionary

Dictionary1 = dict(zip(list2, list1))
print Dictionary1



More information about the Python-list mailing list