我这个用面向过程怎么写

shopping_list = [
   ('Watch', 10000),
   ('Ihpone', 5800),
   ('Bicycle', 800),
   ('Python_book', 65),
   ('Coffee', 31),
]
good_list = []

salary = input("Input your salary:")

def user():
   '''定义用户'''
   for index, item in enumerate(shopping_list):
       print(index, item)
   user_choice = input('Input your buy some of product:')

def unmber( ):
   '''定义unmber这个函数是程序看起来更简化'''
   user()
   x = salary
   y = user_choice
   z = shopping_list

   while True:
     if x.isdigit() or y.isdigit():
           x = int(x)
           y = int(y)
           if x < len(z) and x >= 0:
               s = p_item = z[x]
               if s[1] <= x:
                   z.append(s)
                   x -= s[1]
                   print("Added %s in to shopping cart,"
                         "you current balance is \033[31;1m%s\033[0m"%(s,x))
               else:
                   print("your current balance not to buy is %s"%x)
           else:
               print("Your choice in outside shopping_list")



     elif x or y == 'q':
         print('Wlecome again')

     else:
         print('Invalid Option')

   return





unmber( )

qq_木鱼_14
浏览 1189回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP