[Tutor] help with storing money variable

Alan Gauld alan.gauld at btinternet.com
Tue Feb 19 19:58:56 CET 2013


On 19/02/13 12:36, Ghadir Ghasemi wrote:

> def printMenu():
>      print ("|__________________________|")
>      print ("|  2. Insert 10p           |")
>      print ("|  3. Insert 20p           |")
>      print ("|  4. Insert 50p           |")
>      print ("|__________________________|")
>
> while True:
>      elif choice == '2':
>          money = 0
>          number = int(input("how many 10p: "))
>          money += number * 1/10
>      elif choice == '3':
>          money = 0
>          number2  = int(input("how many 20p: "))
>          money += number2 * 2/10
>      elif choice == '4':
>          money = 0
>          number3 = int(input("how many 50p: "))
>          money += number3 * 5/10

In each case you start by zeroing money thus losing any credit they
had built up. If a real machine did that to me I'd me mighty annoyed.

Just a thought...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list