成都网站建设设计

将想法与焦点和您一起共享

购物车程序

product_list=[("iPhone XS Max 256G",11000),('MacBook Pro 512G',19000),('Bike',800),("Apple Watch Series 4",3500),("Coffee",30),("Alex Python Book",60)]
shopplist_list=[]
salary=input("请输入你的收入:")
ifsalary.isdigit():
    salary=int(salary)
    while True:
        forindex,iteminenumerate(product_list):
            print(index,item)
        user_choice=input("你选择要买:").strip()
        ifuser_choice.isdigit():
            user_choice=int(user_choice)
            ifuser_choiceanduser_choice>=0:
                p_item=product_list[user_choice]
                ifp_item[1]<=salary:
                    shopplist_list.append(p_item)
                    salary=salary-p_item[1]
                    print("added %s into shopping cart,you current balance is %s"%(p_item,salary))
                else:
                    print("你的余额只剩[%s]啦,余额不足"%salary)
            else:
                print("product code [%s] is not exist!"%user_choice)
        elifuser_choice=="q":
            print("---shopping list----")
            forpinshopplist_list:
                print(p[0])
            print("已经购买:",shopplist_list,"还剩",salary,"元")
            break
        else
:
            print("invalid option")
            print("已经购买:", shopplist_list,"还剩", salary,"元")
            break

10余年的安义网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站的优势是能够根据用户设备显示端的尺寸不同,自动调整安义建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联建站从事“安义网站设计”,“安义网站推广”以来,每个客户项目都认真落实执行。


当前题目:购物车程序
链接地址:http://chengdu.cdxwcx.cn/article/giesce.html