Re: Two Dictionaries and a Sum!

2013-05-18 Thread Roy Smith
In article 6012d69f-b65e-4d65-90c4-f04876853...@googlegroups.com, Bradley Wright bradley.wright@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,

Two Dictionaries and a Sum!

2013-05-17 Thread Bradley Wright
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

Re: Two Dictionaries and a Sum!

2013-05-17 Thread Spacelee
for key in prices.keys(): print prices[key]*stock[key] On Sat, May 18, 2013 at 12:19 PM, Bradley Wright bradley.wright@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 = {

Re: Two Dictionaries and a Sum!

2013-05-17 Thread Chris Angelico
On Sat, May 18, 2013 at 2:19 PM, Bradley Wright bradley.wright@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

Re: Two Dictionaries and a Sum!

2013-05-17 Thread nanobio
total,amount=0,0 for key in prices.keys(): price=prices[key]*stock[key] total+=price print %s %s % (price,total) -- http://mail.python.org/mailman/listinfo/python-list

Re: Two Dictionaries and a Sum!

2013-05-17 Thread nanobio
total,amount=0,0 for key in prices.keys(): amount=prices[key]*stock[key] total+=amount print %s %s % (amount,total) -- http://mail.python.org/mailman/listinfo/python-list