Python shopping cart: new version, python shopping cart
#! /User/bin/env python
# A Shopping Cart program
''' Requirement:
Start the shopping cart, ask the user to enter the salary, and then print the item list
Allows users to purchase products based on product numbers
After you select a product, check whether the balance is sufficient. Otherwise, deduct the fee.
You can exit at any time. When you exit, print the purchased items and balances '''
Sal = input ("Enter your salary :")
Show = [("car", "1000"), ("dog", "2000"), ("cat", "100"), ("ball ", "200")]
Show_card = []
Title = "True"
If sal. isdigit ():
Sal = int (sal)
Now_salary = sal
While title:
For I in show:
Print (show. index (I), I)
Choose = int (input ("select your product serial number :"))
If sal> = int (show [choose] [1]):
Print ("3Q, the product you have purchased successfully:", show [choose] [0])
Show_card.append (show [choose])
Now_salary-= int (show [choose] [1])
Result = input ("continue purchasing products? Press q to exit or press any key to continue ")
If result = "q ":
Print ("your items are: % s, your balance is: % s" % (show_card, now_salary ))
Break
Else:
Continue
Else:
Print ("your salary cannot buy this product ")
Break
Else:
Print ("enter a number ")
.
.
.
.
To be continued