#!/user/bin/env python
#一个购物车的程序
"Demand:
Start the shopping cart, let the user enter the payroll, and then print the list of items
Allow users to purchase items based on their product number
After the user selects the product, checks whether the balance is enough, enough on the direct debit, otherwise the reminder
You can exit at any time and print the purchased goods and balances on exit
Sal=input ("Please enter your salary:")
show=[("Car", "+"), ("Dog", "+"), ("Cat", "+"), ("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, you have successfully purchased the product:", show[choose][0])
Show_card.append (Show[choose])
Now_salary-= Int (show[choose][1])
result = Input ("Continue to purchase goods? Press Q to exit or press any key to continue")
if result = = "Q":
Print ("Your product has:%s, your balance is:%s"% (Show_card, now_salary))
Break
Else
Continue
Else
Print ("Your salary is not available to buy this item")
Break
Else
Print ("Please enter a number")
.
.
.
.
Not to be continued
Python implementation Shopping Cart: Beginner Edition