<p dir="ltr"><br>
On 10 Jun 2013 09:34, "Νικόλαος Κούρας" <<a href="mailto:nikos.gr33k@gmail.com">nikos.gr33k@gmail.com</a>> wrote:<br>
><br>
> Trying this:<br>
><br>
> months = { 'Ιανουάριος':1, 'Φεβρουάριος':2, 'Μάρτιος':3, 'Απρίλιος':4, 'Μάϊος':5, 'Ιούνιος':6, \<br>
> 'Ιούλιος':7, 'Αύγουστος':8, 'Σεπτέμβριος':9, 'Οκτώβριος':10, 'Νοέμβριος':11, 'Δεκέμβριος':12 }<br>
><br>
> for key in sorted( months.values() ):<br>
> print('''<br>
> <option value="%s"> %s </option><br>
> ''' % (months[key], key) )<br>
><br>
><br>
> output this:<br>
><br>
> [Mon Jun 10 11:25:11 2013] [error] [client 79.103.41.173] File "/home/nikos/public_html/cgi-bin/pelatologio.py", line 310, in <module>, referer: <a href="http://superhost.gr/">http://superhost.gr/</a><br>
> [Mon Jun 10 11:25:11 2013] [error] [client 79.103.41.173] ''' % (months[key], key) ), referer: <a href="http://superhost.gr/">http://superhost.gr/</a><br>
> [Mon Jun 10 11:25:11 2013] [error] [client 79.103.41.173] KeyError: 1, referer: <a href="http://superhost.gr/">http://superhost.gr/</a><br>
><br>
> KeyError 1 ??!! All i did was to tell python to sort the dictionary values, which are just integers.<br>
> --<br>
> <a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a></p>
<p dir="ltr">KeyError: 1 means that there is no int(1) key. I think you meant to do "for key in sorted(yourdict.keys())"</p>