Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #84037
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.06; 'returned.': 0.07; 'function,': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'jan': 0.12; "(i'm": 0.16; 'determines': 0.16; 'food:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hint:': 0.16; 'interpreter,': 0.16; 'is;': 0.16; 'script,': 0.16; 'wrote:': 0.18; 'result.': 0.19; 'code,': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'indentation': 0.31; 'piece': 0.31; 'anyone': 0.31; 'figure': 0.32; 'know.': 0.32; 'thanks!': 0.32; 'run': 0.32; 'another': 0.32; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'does': 0.39; 'sure': 0.39; 'matter': 0.61; 'total': 0.65; '20,': 0.68; '2015': 0.84; 'stock.': 0.84; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=LYEys0w3iEW7zKPLo/nHQw7xIXNUJKKVVlL3wMv2/qE=; b=Un0Uj1IlNOT/LZPlXnk6WKpY8wbsJU9D6steO56oFu06du8kBKBR2k1Q+wBAjJFqb8 PQtdOmuISPS50mjZABRTyLM+2KWb3Hw8qU3ivovxCX7bDj1sAv3fNzzoFgHgOvcmg5Ul OrF+epsmVqWsrxwiIvVo6VhHOzXUKOPcnFAgQszYyHXQyong0/xfFNUffRwNltDPV9D+ cExxJqX/A8TaH0mp/7IfmxkJQo6w4wxUSaKzTn2eySsKJlfI84UP4G32sY0Ch3016CLG pIEQ5edLjygCznGqvizmulmBsC8DuDhmsIp1uSYlFo3e2KgkB+lCfga3NSSkkr5PkjSB 1EYA== |
| MIME-Version | 1.0 |
| X-Received | by 10.224.43.202 with SMTP id x10mr52327478qae.16.1421713297810; Mon, 19 Jan 2015 16:21:37 -0800 (PST) |
| In-Reply-To | <bc9e302a-356c-4223-9c25-6a8003db48e6@googlegroups.com> |
| References | <bc9e302a-356c-4223-9c25-6a8003db48e6@googlegroups.com> |
| Date | Tue, 20 Jan 2015 11:21:37 +1100 |
| Subject | Re: Concerning Dictionaries and += in Python 2.x |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| 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 | <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17869.1421713307.18130.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1421713307 news.xs4all.nl 2858 [2001:888:2000:d::a6]:49590 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:84037 |
Show key headers only | View raw
On Tue, Jan 20, 2015 at 11:12 AM, Luke Tomaneng <luketomaneng@gmail.com> wrote: > def compute_bill(food): > total = 0 > for item in food: > if stock[item] > 0: > total += prices[item] > stock[item] = stock[item] - 1 > return total > Whenever I run this script, "4" is returned. It does not seem to matter what in in the list the script is run on. I have tried this on the Codecademy interpreter/emulator (I'm not sure which they use) and the repl.it interpreter, but for the same result. If anyone could find the glitch in my code, please let me know. Thanks! > In Python, indentation determines block structure. Have another look at this function, and see if you can figure out where the problem is; hint: try printing something out every time you claim a piece of stock. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Concerning Dictionaries and += in Python 2.x Luke Tomaneng <luketomaneng@gmail.com> - 2015-01-19 16:12 -0800
Re: Concerning Dictionaries and += in Python 2.x Chris Angelico <rosuav@gmail.com> - 2015-01-20 11:21 +1100
Re: Concerning Dictionaries and += in Python 2.x Luke Tomaneng <luketomaneng@gmail.com> - 2015-01-19 16:31 -0800
Re: Concerning Dictionaries and += in Python 2.x MRAB <python@mrabarnett.plus.com> - 2015-01-20 00:27 +0000
Re: Concerning Dictionaries and += in Python 2.x Luke Tomaneng <luketomaneng@gmail.com> - 2015-01-19 16:34 -0800
Re: Concerning Dictionaries and += in Python 2.x Chris Angelico <rosuav@gmail.com> - 2015-01-20 11:46 +1100
Re: Concerning Dictionaries and += in Python 2.x Dan Stromberg <drsalists@gmail.com> - 2015-01-19 16:54 -0800
Re: Concerning Dictionaries and += in Python 2.x Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-21 05:01 +0000
Re: Concerning Dictionaries and += in Python 2.x Peter Otten <__peter__@web.de> - 2015-01-21 09:43 +0100
Re: Concerning Dictionaries and += in Python 2.x Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-21 14:10 +0000
Re: Concerning Dictionaries and += in Python 2.x Peter Otten <__peter__@web.de> - 2015-01-21 09:59 +0100
csiph-web