-- coding:utf-8 --
Author:Tinky
salary = input("请输入你的工资:")
pro_list = [("0.房车",100), ("1.车子", 200), ("2.电动车", 300), ("3.自行车", 400), ("4.滑板车", 500)]
shopping_list = []
if salary.isdigit():
salary = int(salary)
while True:
for index, item in enumerate(pro_list):
print(index, item)
user_choice = input("请选择商品编号:")
if user_choice.isdigit():
user_choice = int(user_choice)
if len(pro_list) > user_choice >= 0:
p_item = pro_list[user_choice]
if p_item[1] <= salary:
shopping_list.append(p_item)
print("Added %s into shoppint car,your current balance is %s" % (shopping_list, salary - p_item[1]))
else:
print("\033[41:1m你的余额为[%s]啦\033[31:0m" % (salary - p_item[1]))
else:
print("\033[40:1m商品%S不存在\033[32:0m" % pro_list[user_choice])
elif user_choice == "q":
exit("退出程序")
else:
print("invalid option")