十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
#Author Kang
shopping_list = [('Iphone',5000),('MacBook',9000),('Huwei P20',9999)]
shopping_car = []
salary = int(input('请输入你的工资:'))
while True:
for index,item in enumerate(shopping_list):
print(index,item)
user_change = input('请输入你要购买的产品编号:')
if user_change.isdigit():
user_change=int(user_change)
if user_change >= 0 and user_change < len(shopping_list) and salary >= shopping_list[user_change][1]:
shopping_car.append(shopping_list[user_change])
salary -=shopping_list[user_change][1]
elif salary <= shopping_list[user_change][1] :
print('你的余额已经不足!!!')
else:
print('你输入的编号有误,请重新输入!!!!!')
elif user_change == 'q':
print('--------已购买的产品-------')
print(shopping_car)
print('剩下的余额为>>>:',salary)
exit()
else:
print("输入有误,请重新输入")