Small scale chopper - Shopping Cart

#author: Zhang Hao 
#date: 2019/8/14
list_goods = [
[ 'iphone6s', 5800],
[ 'MAC Book', 9000],
[ 'Coffee', 30],
[ 'Python Book', 80],
[ 'the Bicycle', 1500]
]
the while True:
salary = the iNPUT ( 'Please enter the recharge amount:')
shopping_car = []
IF salary.isdigit ():
salary = int (salary)
the while True:
Print ( "the following is a list of goods : ")
for goods in list_goods:
Print (list_goods.index (goods) +1,", ", goods)
Choice = the iNPUT (" Please enter the serial number want to buy goods, enter q to quit: ")
IF choice.isdigit ( ):
choice = int(choice)
if 0 < choice <= len(list_goods):
list_goods IF [-Choice. 1] [. 1] <= the salary:
shopping_car.append (list_goods [Choice -. 1])
Print ( "% s was product was added to cart"% list_goods [-Choice. 1])
the salary the salary = - list_goods [-Choice. 1] [. 1]
the else:
Print ( "insufficient funds, the money remaining:% S" the salary%)
the else:
Print ( "! product number input does not exist")
elif Choice == "Q":
Print ( " purchased goods as follows: ")
for goods_buy in shopping_car:
Print (shopping_car.index (goods_buy) + 1, goods_buy)
Print (" balance:% s "%salary)
break
else:
print ( "input is incorrect, please re-enter!")
BREAK
the else:
print ( "input is incorrect, please re-enter!")

Guess you like

Origin www.cnblogs.com/zzzhao/p/11350903.html