Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46066
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python3': 0.07; 'subject:Error': 0.07; '8bit%:78': 0.09; 'dropdown': 0.09; 'line:': 0.09; 'mixed': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:trying': 0.09; "'''": 0.16; 'key)': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:when': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'coding': 0.22; 'header :User-Agent:1': 0.23; 'error': 0.23; 'values': 0.27; '2010,': 0.27; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; "doesn't": 0.30; 'gives': 0.31; 'code': 0.31; "skip:' 10": 0.31; 'keyerror:': 0.31; 'keys': 0.31; 'file': 0.32; 'there.': 0.32; '(most': 0.33; '8bit%:80': 0.36; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; '8bit%:74': 0.68; '8bit%:67': 0.93; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Error when trying to sort and presnt a dictionary in python 3.3.1 |
| Date | Sun, 26 May 2013 14:20:19 +0200 |
| Organization | None |
| References | <95e674bf-0d96-479c-b7a4-9242768a7a46@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Gmane-NNTP-Posting-Host | p5084a359.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2172.1369570798.3114.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369570798 news.xs4all.nl 16008 [2001:888:2000:d::a6]:35035 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:46066 |
Show key headers only | View raw
Νίκος Γκρ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 ;(
Back to comp.lang.python | Previous | Next — Previous in thread | 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