Νίκος Γκρ33κ wrote: > 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 }
You have keys and values mixed up... > print(''' > <form method="post" action=""> > <select name="month"> > ''') > > for key in sorted( months.values() ): and calling the value key doesn't help there. > print(''' > <option value="%s"> %s </option> > ''' % (months[key], key) ) At some point you have to admit that coding isn't your cup of tea. Or Ouzo ;( -- http://mail.python.org/mailman/listinfo/python-list