Shopping Cart program, python Shopping Cart program
_ Author _ = 'xitaozi''' use the list to implement the shopping cart ''' produce _ list = [('macbook pro 100', 15.4 ), ('Think pad X1 carbon ', 10000), ('hp WASD', 7000), ('Dell xps 13', 8000)] while True: budget = input ("Enter the shopping budget:") shopping_list = [] if budget. isdigit (): budget = int (budget) while True: for (item, product) in enumerate (produce_list): print (item, product) user_choice = input ("Select product ID, add to shopping cart. Enter the letter 'q' to exit ") if user_choice.isdigit (): user_choice = int (user_choice) if user_choice <len (produce_list) and user_choice> = 0: p_item = produce_list [user_choice] if p_item [1] <= budget: shopping_list.append (p_item) budget = budget-p_item [1] print ("% s shopping cart added successfully, your budget balance is % d. "% (P_item, budget) else: print (" your budget balance is: % d And you cannot continue purchasing. "% Budget) else: print (" item number input error. Please enter it again. ") Elif user_choice = 'q' or user_choice = 'q': print (" -------- your shopping cart has the following items -------- ") for shop_item in shopping_list: print (shop_item) exit () else: print ("input error") else: print ("input error. Run the program again. ")