首页 > 其他 > 详细

这是一个购物车代码 可能还不完善 望各位指教

时间:2019-08-19 15:56:37      阅读:77      评论:0      收藏:0      [点我收藏+]
product_list=[
(‘iphone‘,5000),
(‘car‘,500400),
(‘book‘,50),
(‘bicycle‘,500),
(‘computer‘,22200),
]
shop_car=[]
user_name="liuxi"
login_password=1763335968
input_name=input("plese import you id:")
input_password=int(input(‘plese import you password:‘))

if input_name == user_name and input_password ==login_password:
wallet=input(‘plese fill down how much money you have:‘)
if wallet . isdigit() :
wallet=int(wallet)
while True:
for i,c in enumerate(product_list,1):
print(i,c)
choise_shop=input(‘which goods you want [quir:q]:‘)
if choise_shop .isdigit():
choise_shop=int(choise_shop)
if choise_shop<= len(product_list):
pick_shop=product_list[choise_shop-1]
else :
print("plese fill number one to " ,len(product_list))
if wallet > pick_shop[1]:
wallet -=pick_shop[1]
shop_car.append(pick_shop[0])
else :
print(‘you wallet not enough plese try cheaper goods‘)
elif choise_shop == ‘q‘:
print(‘you will quit ‘)
print(‘------you have buy these comdity----- ‘)
for s in shop_car:
print(s)
print(‘you wallet remain %s yuan ‘%wallet)
break
else :
print(‘plese fill right format‘)


else:
print(‘plese fill ture number‘)

else :
print(‘plese import ture id or password‘)

这是一个购物车代码 可能还不完善 望各位指教

原文:https://www.cnblogs.com/CIBud/p/11377476.html

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