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: 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 To: Bradley Wright 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --047d7b342f0e32227b04dcf69091 Content-Type: text/plain; charset=UTF-8 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* --047d7b342f0e32227b04dcf69091 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
for key in prices.keys():
=C2=A0 =C2=A0 print price= s[key]*stock[key]


On Sat,= May 18, 2013 at 12:19 PM, Bradley Wright <bradley.wright.biz@g= mail.com> wrote:
Confusing subject for a confusing problem (t= o a novice like me of course!)
Thx for the help in advance folks

I have (2) dictionaries:

prices =3D {
=C2=A0 =C2=A0 "banana": 4,
=C2=A0 =C2=A0 "apple": 2,
=C2=A0 =C2=A0 "orange": 1.5,
=C2=A0 =C2=A0 "pear": 3
}

stock =3D {
=C2=A0 =C2=A0 "banana": 6,
=C2=A0 =C2=A0 "apple": 0,
=C2=A0 =C2=A0 "orange": 32,
=C2=A0 =C2=A0 "pear": 15
}

Here's my instructions:

consider this as an inventory and calculate the sum (thats 4*6 =3D 24 banan= as!)

HERES MY CODE:

for key in prices:
=C2=A0 =C2=A0 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
--047d7b342f0e32227b04dcf69091--