#Author: Gordon
salary = int(input("请输入你的工资:"))
goods = [('0',"Iphone",5000),('1','Laptop',3500),('2','Coffee',20),('3','Chocolate',20)]
bought =[]
while True:
want = input("请输入要买的商品编号:")
if want.isdigit():
want = int(want)
if want > 0 and want < len(goods):
if salary > goods[want][2]:
bought.append(goods[want][1])
print(goods[want][1], "商品已经加入到你的购物车!")
salary = salary - goods[want][2]
print("你的余额还有:", salary)
else:
print("您的余额已经不足")
else:
print("对不起,我们没有这件物品")
elif want == 'q':
break
else:
print("这个无效的option")
print("你已经买了",bought)
print("你的余额是:",salary)
05-11 17:55