标签:tin git [1] for [] index col ack pre
shopping=[(‘toy‘,50),
(‘clothes‘,100),
(‘iphone‘,5000),
(‘bike‘,400),
(‘hat‘,20),
(‘food‘,100)]
buy_shopping=[]
salary=int(input(‘input your salary:‘))
while True:
for index,item in enumerate(shopping):
print(index,item)
choice_num = input(‘input your miss choice shopping num:‘)
if choice_num.isdigit():
choice_num = int(choice_num)
if choice_num<len(shopping) and choice_num>=0:
choice_shopping=shopping[choice_num]
if choice_shopping[1]<=salary:
salary -= choice_shopping[1]
print(‘buy shopping:‘,choice_shopping[0])
print(‘balance:‘,salary)
else :
print(‘your money not enough,again choice:‘)
break
else:
continue
buy_shopping.append(choice_shopping[0])
for p in buy_shopping:
print(‘your buy shoping is:‘,p)
标签:tin git [1] for [] index col ack pre
原文地址:https://www.cnblogs.com/0429yang/p/9517263.html