Sorting a set works, sorting a dictionary fails ?

Νικόλαος Κούρας nikos.gr33k at gmail.com
Mon Jun 10 06:20:27 EDT 2013


Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε:
> Am 10.06.2013 10:29, schrieb Νικόλαος Κούρας:
> 
> > for key in sorted( months.values() ):
> 
>        ^^^                   ^^^^^^
> 
> 
> 
> > KeyError 1 ??!! All i did was to tell python to sort the dictionary values, which are just integers.
> 
> 
> 
> ...and which you then proceed to use as key, which is obviously wrong.

How hsould have i written it then?



More information about the Python-list mailing list