首页 > 其他 > 详细

简单购物程序

时间:2019-05-21 23:47:22      阅读:130      评论:0      收藏:0      [点我收藏+]

while True:
salary = input("salary:")
if salary.isdigit():
salary=int(salary)
product_list=[["iphone",5800],
["外星人电脑",9000],
["卡布奇诺",32],
["哲学",80],
["自行车",1500]]
print(len(product_list))
for index,element in enumerate(product_list,1):
print(index,element)

shopping_list=[]
while True:
choice = input("choice:")
if choice.isdigit():
choice=int(choice)
product_list[choice-1][1]<=salary:
shopping_list.append(product_list[choice-1][0])
print(shopping_list)
else:
print("选择编码不在合理范围内,重新选择")
elif choice=="q":
print("您的购物清单")
for i in shopping_list:
print(i)
print("--------------------------------------")
print("欢迎下次光临")
break
else:
print("输入的选择不是数字,则重新选择")
break
else:
print("invalid salary,input salary again")

大部分自己手打的,有一些是百度上查的。(别抄我的)

简单购物程序

原文:https://www.cnblogs.com/qianlanbaba/p/10903196.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!