Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104496
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Erik <python@lucidity.plus.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Simple exercise |
| Date | Thu, 10 Mar 2016 09:38:46 +0000 |
| Lines | 34 |
| Message-ID | <mailman.121.1457602735.15725.python-list@python.org> (permalink) |
| References | <CABRP1o-c+Y7U9owb7_g9WU71FjNo6GT7XVhcuQqgasMrsv2GtA@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de KvWzbzQVYir3eRts108lUAi4ce4iYyAy5sIsS+AZWu8Q== |
| Return-Path | <python@lucidity.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.034 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; 'else:': 0.03; 'cryptic': 0.16; 'from:addr:python': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'something.': 0.16; 'wrote:': 0.16; 'input': 0.18; 'to:name:python-list@python.org': 0.20; 'to:2**1': 0.21; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'looks': 0.29; 'doing?': 0.29; 'problem': 0.33; 'subject:Simple': 0.33; "i'll": 0.33; 'except': 0.34; 'item': 0.35; 'skip:i 20': 0.36; 'lines': 0.36; 'apple': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'charset:windows-1252': 0.62; 'more': 0.63; 'carefully': 0.72; 'homework': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=Rr04V3SK c=1 sm=1 tr=0 a=X2VfThTz+8HMaRSzjuZh7Q==:117 a=X2VfThTz+8HMaRSzjuZh7Q==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=N659UExz7-8A:10 a=ZjWjHIIkauc0BM9oGe0A:9 a=pILNOxqGKmIA:10 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
| In-Reply-To | <CABRP1o-c+Y7U9owb7_g9WU71FjNo6GT7XVhcuQqgasMrsv2GtA@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:104496 |
Show key headers only | View raw
Hi. This looks a little like a homework problem, so I'll be cryptic ... :) On 10/03/16 09:02, Rodrick Brown wrote: >>From the following input > > 9 > BANANA FRIES 12 > POTATO CHIPS 30 > APPLE JUICE 10 > CANDY 5 > APPLE JUICE 10 > CANDY 5 > CANDY 5 > CANDY 5 > POTATO CHIPS 30 <snip> > if m: > if m.group(1) not in od.keys(): > od[m.group(1)] = int(m.group(2)) > else: > od[m.group(1)] += int(od.get(m.group(1),0)) Look very carefully at the last line above. What is it _actually_ doing? Also, consider that for each of the input lines all of the items that occur more than once exactly double the current value each time they are repeated. Except "CANDY", which is the item you are having a problem with ... that may tell you something. E.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Simple exercise Erik <python@lucidity.plus.com> - 2016-03-10 09:38 +0000
csiph-web