Erlo

python_3

2019-10-27 00:00:16 发布   337 浏览  
页面报错/反馈
收藏 点赞

购物车:

product_list=[
("TV",2000),
("Ipad",4000),
("Bike",1000),
("Book",500)
]
shopping_list=[]

money=input("Please input your current money:")

if money.isdigit():
money=int(money)
while True:
for index,item in enumerate(product_list):
print(index,item)
user_choice=input("Please choose what you want to buy:")
if user_choice.isdigit():
user_choice=int(user_choice)
if user_choice< len(product_list) and user_choice>=0:
p_item=product_list[user_choice]
if p_item[1] <= money:
shopping_list.append(p_item)
money -= p_item[1]
print("Added %s into shopping cart,your current money is
登录查看全部

参与评论

评论留言

还没有评论留言,赶紧来抢楼吧~~

手机查看

返回顶部

给这篇文章打个标签吧~

棒极了 糟糕透顶 好文章 PHP JAVA JS 小程序 Python SEO MySql 确认