首页 > 其他 > 详细

简单购物车

时间:2017-12-15 20:39:49      阅读:213      评论:0      收藏:0      [点我收藏+]
#简单购物车,要求如下:
实现打印商品详细信息,用户输入商品名和购买个数,则将商品名,价格,购买个数加入购物列表,如果输入为空或其他非法输入则要求用户重新输入 
msg_dic={
apple:10,
tesla:100000,
mac:3000,
lenovo:30000,
chicken:10,
}
good_l=[]
while True:
    for k in msg_dic:
        print(k,msg_dic[k])
    name=input(商品名称:,).strip()
    while True:
        count=input(购买个数:)
        if count.isdigit():
            break
    good_l.append((name,msg_dic[name],int(count)))
    print(good_l)
    if len(name)==0 or name not in msg_dic:
        print(非法输入)
        continue

 

简单购物车

原文:http://www.cnblogs.com/zhanglin123/p/8044711.html

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