Reply to post 'Tryign to add a valkue to a set'

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


Since dict.keys() return a list of the keys in the dict and the keys are associated with the dict's values why doesnt it work the other way around too?

I'm talking about this:
[code]
for key in sorted( months.keys() ): 
         print(''' 
                 <option value="%s"> %s </option> 
         ''' % (months[key], key) ) 

[/code]

I could have uses ordered by kees but that orders key alphabetically, and montha re not displayed in the usual row. ordering by values though it would be a perfect fit.



More information about the Python-list mailing list