Reply to post 'Tryign to add a valkue to a set'
Νικόλαος Κούρας
nikos.gr33k at gmail.com
Mon Jun 10 10:03:39 EDT 2013
Τη Δευτέρα, 10 Ιουνίου 2013 4:14:33 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε:
> Am 10.06.2013 12:57, schrieb Νικόλαος Κούρας:
>
> > >Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich
>
> > Eckhardt έγραψε:
>
> >
>
> > for key in sorted( months.keys() ):
>
> > print('''
>
> > <option value="%s"> %s </option>
>
> > ''' % (months[key], key) )
>
> >
>
> > this in fact works, it sorts the dict by its keys()
>
>
>
> No, it does not sort the dict. Please slow down, relax and take a look
>
> at the documentation of sorted(). You are jumping to conclusions based
>
> on flawed expectations and assumptions, which can only yield garbage in
>
> the end.
>
>
>
> Uli
It soerts it just fine by keys() alpabeticall but this isnt what i want, i need sorting by values()
for key in sorted( months.values() ):
print('''
<option value="%s"> %s </option>
''' % (key, what should_we put here_to get the actual months
name? )
the value is a vale form the values in order, but how do i specify the correspondign key to that value?
More information about the Python-list
mailing list