Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45491
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fjctlzy@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.051 |
| X-Spam-Evidence | '*H*': 0.90; '*S*': 0.00; 'advance': 0.07; 'issue:': 0.09; 'thx': 0.09; 'cc:addr:python-list': 0.11; '1.5,': 0.16; '32,': 0.16; 'subject:Two': 0.16; 'folks': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'wright': 0.31; 'url:python': 0.33; 'problem': 0.35; '(2)': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'skip:& 10': 0.38; 'pm,': 0.38; 'stock': 0.39; 'skip:p 20': 0.39; 'space': 0.40; 'url:mail': 0.40; 'prices': 0.60; 'sum': 0.64; 'to:addr:gmail.com': 0.65; 'subject': 0.69; 'confusing': 0.84; 'prices:': 0.84; 'novice': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=nDqHdJl3bLQULQaLFSbnzu315K3PiLedHNSYzRPSN5Y=; b=sxar2bFdmwWz0TJ1F7JtlLQAv6w/59Ka3jSaSO8u3oQ9SOJ3ZcqDN/qoSOOGzIq+Ul ahPP5w8Dln+CQ0+DPCh6uQiX4u1Ws4Ps7n6cn5ZMh4+S1ur592HbGQLylF6rxFnPzHND 8klhEigQE3+gzvVrOgBaGgDrywWFHdFByhAvuTs6eH3xZaapSkC7Dmb0H2BCypFbmjZB gmcNzdPYHIpNvdZdyhZ1dvKjZQMKkf2YzFWZnv0ruI+1XyGYy9om9cn6ol7TT6hXeOJr +ipwutA4izl+bArh3AlbPAdDBgKHfHy/1TJS3qGGQQ43vdouNgGdsYeZsFqEQyzXfgvE zoFw== |
| MIME-Version | 1.0 |
| X-Received | by 10.220.112.16 with SMTP id u16mr941120vcp.40.1368851446110; Fri, 17 May 2013 21:30:46 -0700 (PDT) |
| In-Reply-To | <6012d69f-b65e-4d65-90c4-f04876853f5e@googlegroups.com> |
| References | <6012d69f-b65e-4d65-90c4-f04876853f5e@googlegroups.com> |
| Date | Sat, 18 May 2013 12:30:45 +0800 |
| Subject | Re: Two Dictionaries and a Sum! |
| From | Spacelee <fjctlzy@gmail.com> |
| To | Bradley Wright <bradley.wright.biz@gmail.com> |
| Content-Type | multipart/alternative; boundary=047d7b342f0e32227b04dcf69091 |
| Cc | python-list@python.org |
| 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.1792.1368851449.3114.python-list@python.org> (permalink) |
| Lines | 119 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1368851449 news.xs4all.nl 15969 [2001:888:2000:d::a6]:51150 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:45491 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
for key in prices.keys():
print prices[key]*stock[key]
On Sat, May 18, 2013 at 12:19 PM, Bradley Wright <
bradley.wright.biz@gmail.com> wrote:
> Confusing subject for a confusing problem (to a novice like me of course!)
> Thx for the help in advance folks
>
> I have (2) dictionaries:
>
> prices = {
> "banana": 4,
> "apple": 2,
> "orange": 1.5,
> "pear": 3
> }
>
> stock = {
> "banana": 6,
> "apple": 0,
> "orange": 32,
> "pear": 15
> }
>
> Here's my instructions:
>
> consider this as an inventory and calculate the sum (thats 4*6 = 24
> bananas!)
>
> HERES MY CODE:
>
> for key in prices:
> print prices[key]*stock[key]
>
> HERES THE OUTPUT:
>
> 48.0
> 45
> 24
> 0
>
> ISSUE:
> I need to find a way to add all of those together...any pointers?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
*Space Lee*
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Two Dictionaries and a Sum! Bradley Wright <bradley.wright.biz@gmail.com> - 2013-05-17 21:19 -0700 Re: Two Dictionaries and a Sum! Spacelee <fjctlzy@gmail.com> - 2013-05-18 12:30 +0800 Re: Two Dictionaries and a Sum! nanobio <hektorlg@gmail.com> - 2013-05-17 22:20 -0700 Re: Two Dictionaries and a Sum! nanobio <hektorlg@gmail.com> - 2013-05-17 22:22 -0700 Re: Two Dictionaries and a Sum! Chris Angelico <rosuav@gmail.com> - 2013-05-18 15:10 +1000 Re: Two Dictionaries and a Sum! Roy Smith <roy@panix.com> - 2013-05-18 09:22 -0400
csiph-web