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( )
1 回答
- 1 回答
- 0 关注
- 1188 浏览
添加回答
举报
0/150
提交
取消