【发布时间】:2014-12-18 05:39:57
【问题描述】:
我正在为我的 GCSE 课程编写一个程序,它的工作原理类似于自动售货机。我试图从重写的变量中减去一个变量,但由于某种原因它不起作用。帮忙?
This is my code:
credit=raw_input("Please input your change, CAREFUL! This Machine only accepts 10p,20p,50p and £1: ")
list1= ["1", "2", "3", "4", "5"]
price1=0.65
price2=0.70
price3=0.50
price4=0.70
price5=0.80
while (credit) == 0:
(credit)=raw_input("Please input your change: ")
products = (" 1) Kinder Bueno\n 2) Doritos Chilli Heatwave\n 3) Nestle Yorkie Bar\n 4) Coca Cola(Can)\n 5) Volvic Stawberry Water")
print (credit)
print ("The product selection is the following")
print (products)
(selection)=raw_input("Please select a product: ")
if (selection) == (list1[0]):
(new_credit)=int(credit-price1)
print (new_credit)
【问题讨论】:
标签: python python-2.7 typeerror