#_author:"Jack Ma"
#date: 2017/11/12

Goods_list = [
("xiaomi note 3",2500),
("xiaomi pro",7000),
("xiaomi hands",150),
("xiaomi eraphone",120),
("xiaomi notebooks",50)
]
shopping_list = []
salary = input("请输入您的工资:")
if salary.isdigit():
salary = int(salary)
while True:
for index,item in enumerate(Goods_list,1):
print(index,item)
choicegoods = input("请输入您选择的商品编号:")
if choicegoods.isdigit():
choicegoods = int(choicegoods)
if choicegoods < len(Goods_list) and choicegoods >= 0 :
p_item = Goods_list[choicegoods - 1]
if p_item[1] < salary:
salary -= p_item[1]
shopping_list.append(p_item)
print("已将%s放入您的购物车,余额为:%s"%(p_item,salary))
else:
print("您的余额不足,还剩%s"%salary)
else:
print("您输入的编号不存在!")
elif choicegoods == 'quit':
print("--------您购买的商品如下-------")
print("商品名 单价")
for item in shopping_list:
print(item)
print("您还剩%s元钱!"%salary)
print("欢迎您下次光临!")
break
else:
print("请输入您的工资:")