• python: for practice and trianing case purchase cart


    commodity_list=[('bicycle',9000),('iphone',20000),('tesla',20000),('python book',109),('mac book',2000)]

    deposit=input('please input your budget:')

     if deposit.isdigit():

        deposit=int(deposit)

        purchase_item=[]

        while True:

           for i,v in enumerate(commodity_list,1):

               print(i,'----',v)

               choice=input('input your choice Commodity No【Quite:q]')

                if choice.isdigit():

                  choice=int(choice)

                  p_item=commodity_list[choice]

                  if deposit>p_item[1]:

                    print('your choice is %s,your balance is %s'%p_item,deposit)

                    purchase_item.append(p_item)

                    deposit-=p_item[1]

               elif  choice=='q':

                 print('------your list---------')

                   for i in purchase_item:

                        print(i)

                        print('your balance is %s',%deposit)

                          break

              else:

                print('please input right Commodity No')

    else:

       print('invalid string literal')

  • 相关阅读:
    iOS获取系统时间
    iOS面试-assign与retain
    iOS-检测网络可连接性
    iOS-ASI异步下载图片
    iOS-NSString值为Unicode格式(字符串编码转换成中文编码)
    iOS-模态视图动画
    iOS-UIScrollView滚动视图(转)
    iOS-NSFileManager
    iOS-self.用法
    iOS-iphone网络编程总结
  • 原文地址:https://www.cnblogs.com/alansuny/p/12437186.html
Copyright © 2020-2023  润新知