Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46061
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-05-26 04:11 -0700 |
| Message-ID | <95e674bf-0d96-479c-b7a4-9242768a7a46@googlegroups.com> (permalink) |
| Subject | Error when trying to sort and presnt a dictionary in python 3.3.1 |
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
python3 pelatologio.py gives me error in this line:
Traceback (most recent call last):
File "pelatologio.py", line 283, in <module>
''' % (months[key], key) )
KeyError: 1
The code is:
#populating months into a dropdown menu
years = ( 2010, 2011, 2012, 2013 )
months = { 'Ιανουάριος':1, 'Φεβρουάριος':2, 'Μάρτιος':3, 'Απρίλιος':4, 'Μάϊος':5, 'Ιούνιος':6, \
'Ιούλιος':7, 'Αύγουστος':8, 'Σεπτέμβριος':9, 'Οκτώβριος':10, 'Νοέμβριος':11, 'Δεκέμβριος':12 }
print('''
<form method="post" action="">
<select name="month">
''')
for key in sorted( months.values() ):
print('''
<option value="%s"> %s </option>
''' % (months[key], key) )
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Error when trying to sort and presnt a dictionary in python 3.3.1 Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 04:11 -0700
Re: Error when trying to sort and presnt a dictionary in python 3.3.1 Peter Otten <__peter__@web.de> - 2013-05-26 14:20 +0200
Re: Error when trying to sort and presnt a dictionary in python 3.3.1 Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 05:58 -0700
Re: Error when trying to sort and presnt a dictionary in python 3.3.1 Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 09:09 -0700
csiph-web