__Author__="nanjiang"
wish_list=[
('中级编辑证书',2023 ),
('雅思',2024 ),
('欧洲行',2024 ),
('近视眼手术',2025),
]
wishing_list=[]
salary = input("input your salary:")
if salary. isdigit():
salary = int(salary)
while True:
for index, item in enumerate(wish_list):
print(index,item)
user_choice = input("要实现的愿望?>>>:")
if user_choice.isdigit():
user_choice = int(user_choice)
if user_choice < len(wish_list) and user_choice >= 0:
w_item = wish_list[user_choice]
if w_item[1] <= salary:
wishing_list.append(w_item)
salary -= w_item[1]
print("Added %s into shopping cart,your current balance is \033[31;1m%s\033[0m" % (w_item, salary))
else:
print("\033[41;1m你的余额只剩[%s]啦,实现愿望,还要努力搬砖哦\033[0m" % salary)
else:
print("product code [%s] is not exist!" % user_choice)
elif user_choice == 'q':
print('----whishing list----')
for w in wishing_list:
print(w)
pint("ypur currrent balance:",salary)
exit()
else:
print("invalid option")
标签:salary,愿望,print,list,choice,item,user,清单 From: https://www.cnblogs.com/nanjiang123/p/16757862.html