[Tutor] list, tuple or dictionary
ADRIAN KELLY
kellyadrian at hotmail.com
Tue Nov 29 22:25:17 CET 2011
Sound Wayne, thank you
From: waynejwerner at gmail.com
Date: Tue, 29 Nov 2011 15:11:46 -0600
Subject: Re: [Tutor] list, tuple or dictionary
To: kellyadrian at hotmail.com
CC: tutor at python.org
On Tue, Nov 29, 2011 at 3:04 PM, ADRIAN KELLY <kellyadrian at hotmail.com> wrote:
thanks guy, i was thinking of using a dictionary:- Stock_list = {"White Bread": 1.24, "Biscuits": 1.77, "Banana" : 0.23, "Tea Bags" : 2.37,
"Eggs" : 1.23, "Beans" : 0.57}
how would i go about adding, for example tea and eggs to get a subtotal?
Why, you would add tea and eggs, of course!
print("Subtotal: ", Stock_list["Tea Bags"] + Stock_list["Eggs"])
HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111129/02efe304/attachment.html>
More information about the Tutor
mailing list