[Tutor] list, tuple or dictionary
Wayne Werner
waynejwerner at gmail.com
Tue Nov 29 22:11:46 CET 2011
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/0a7a55e4/attachment.html>
More information about the Tutor
mailing list