首页 > 其他 > 详细

简单电商购物程序

时间:2019-05-21 23:39:32      阅读:94      评论:0      收藏:0      [点我收藏+]

# author : tang
# qq : 1440535574
# time : 2018/4/27 9:51:15


producty_list = [
(‘computer‘, 5000),
(‘xiaomi6‘, 2500),
(‘bed‘, 500),
(‘chair‘, 280),
(‘cup‘, 5)

]
shopping_list = []
info = """----- supermarket info -----
1.Please enter the goods number you want to buy
2.input quit to quit
3.input check to check your shop cart
4.input good to see goods
"""
print(info)

while True:
money = input("please input your money:")
if money.isdigit():
if int(money) >= 0:
money = int(money)
break
else:
print("input money is wrong!")
continue


def good():
for i, item in enumerate(producty_list):
print(i, item)


good()

while True:

buy = input("input the good number ,or quit or check:")
if buy == ‘quit‘:
print("good bye")
break
if buy == ‘good‘:
good()
continue
elif buy == ‘check‘:
print("Shop cart has", shopping_list)
continue

if buy.isdigit():
buy = int(buy)
if buy in range(len(producty_list)):
if money >= producty_list[buy][1]:
producty_name = producty_list[buy][0]
money -= producty_list[buy][1]
shopping_list.append(producty_list[buy][0])
print("{0} has added to your shoppong cart,you have {1} yuan left.".format(producty_name, money))

else:
print("you don‘t have enough money!")
else:
print("There‘s no goods you want here")
else:
print("I cant understand what you want to buy.....")
---------------------
作者:唐高亮
来源:CSDN
原文:https://blog.csdn.net/qq_35627795/article/details/80109364
版权声明:本文为博主原创文章,转载请附上博文链接!

简单电商购物程序

原文:https://www.cnblogs.com/lei521yin/p/10903070.html

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