# _Author:huang
# date: 2017/11/26
# 简单的购物车程序
money = input("money:")
product_list = [
("Mac", 9000),
("Kindle", 300),
("Tesla", 8000),
("book", 60),
("bike", 400)
]
shopping_car = []
if money.isdigit():
money = int(money)
while True:
for i, v in enumerate(product_list, 1):
print(i, '>>>', v)
choice = input("请输入商品编号:[退出:q]:")
if choice.isdigit():
choice = int(choice)
if choice >= 0 and choice <= len(product_list):
p_item = product_list[choice-1]
if p_item[1] < money:
money -= p_item[1]
shopping_car.append(p_item)
print(p_item)
else:
print("余额为%s,余额不足"% money)
else:
print("编码不存在!")
elif choice == 'q':
print("-----你后买的商品如下----")
for i in shopping_car:
print(i)
print("你的余额为:%s"% money)
break
else:
print("无效输入")
else:
print("Invialue number")