Can python create a dictionary from a list comprehension?

Wim Vogelaar wim.vogelaaratmc2worlddotorg
Mon May 28 04:37:12 EDT 2007


>
> why this output isn't ordered, giving:
> {2: 3, 4: 5, 6: 7, 8: 9, 10: 11 }
>
>

I made the original list two elements longer: a = 
[1,2,3,4,5,6,7,8,9,10,11,12]

and to my surprise the output is now ordered, giving: {2: 3, 4: 5, 6: 7, 8: 
9, 10: 11, 12: 13}

I am running ActiveState ActivePython 2.5

 





More information about the Python-list mailing list