标签:foo opp user hone watch 获得 购物 输入 pre
product_list = [
("Aphone", 5000),
("Watch",1000),
("Book", 100),
("Food", 50),
]
shopping_list = []
salary = input("Input of your salary:")
if salary.isdigit():
salary = int(salary)
while True:
for index ,item in enumerate(product_list):
print(index ,item)
user_choice = input(">>>> 你选物品")
if user_choice.isdigit():
user_choice = int(user_choice)
if user_choice <len(product_list) and user_choice >= 0:
choice_list = product_list[user_choice]
if choice_list[1] <= salary:
shopping_list.append(choice_list)
salary -= choice_list[1]
print("恭喜你获得 %s ,你的余额为 \033[31;1m %s\033[0m" %(choice_list , salary) )
else:
print("\033[41;1m 你的余额不足,请充值,谢谢!\033[0m")
else:
print("你选择的%s不在列表里"%(user_choice))
elif user_choice == "Q":
print("shopping_list")
for p in shopping_list:
print(p)
print("你剩余余额:\033[32;1m %s\033[0m"%(salary))
exit()
else:
print("你的输入有误!")
标签:foo opp user hone watch 获得 购物 输入 pre
原文地址:https://www.cnblogs.com/smile-donggua/p/8981560.html