首页 > 其他 > 详细

购物车

时间:2018-10-09 16:09:52      阅读:191      评论:0      收藏:0      [点我收藏+]
list = [('iphone',12000),('iwatch',4200),('book',45),('water',3)]
shopp = []
money = input('input your money:')
if money.isdigit():
    money = int(money)
    while True:
        for index,i in enumerate(list):
            print(index+1,i)
        pamage = input('input shop number:')
        if pamage.isdigit():
            pamage = int(pamage)
            if pamage > 0 and pamage <= len(list):
                if pamage > len(list):
                    print('your num is out')
                else:
                    if list[pamage - 1][1] <= money:
                        money = money - list[pamage - 1][1]
                        print('------------------------------------------------')
                        print('your buy shop is \033[32;1m{shop}\033[0m,and your will out \033[31;1m{Money}\033[0m,and your money stay \033[42;1m{stay}\033[0m'.format(shop =list[pamage-1][0],Money=list[pamage-1][1],stay=money))
                        print('------------------------------------------------')
                        shopp.append(list[pamage-1][0])
                    else:
                        print('your money not inf')
            elif pamage > len(list):
                print('your number outing')
        elif pamage.lower() == 'q':
            for p in shopp:
                print('thid id your shop:\033[34;1m{0}\033[0m'.format(p))
            print('your money last \033[41;1m{0}\033[0m'.format(money))
            exit()
        else:
            print('input error,please checking')
else:
    print('please input number')

购物车

原文:https://www.cnblogs.com/Arthur7/p/9760800.html

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