Shopping cart There are some questions behind the Python job please God help to perfect it, thank you ha

Source: Internet
Author: User

Functional Requirements:

Require users to enter total assets, for example: 2000
Display the list of items, let the user select the item according to the serial number, add the shopping cart
Purchase, if the total amount of goods is greater than the total assets, indicating that the account balance is insufficient, otherwise, the purchase succeeds.
Add: Can recharge, a product to remove the shopping cart
goods = [
{"Name": "Computer", "Price": 1999},
{"Name": "Mouse", "Price": 10},
{"Name": "Yacht", "Price": 20},
{"Name": "Beauty", "Price": 998},
]

 goods = [
{"name": "Computer", "Price": 1999},
{"name": "Mouse", "Price": ten},
{"name": "Yacht", "Price": 20 },
{"name": "Beauty", "Price": 998},
]
zzc = int (input (' Please enter total assets: '))
car = []
while True:
for I1 in EN Umerate (Goods):
Print (i1[0],i1[1].get (' name '), I1[1].get (' price '))
ret = int (input (' Please select an item according to the ordinal, exit input 88: ')) br> for I2 in Enumerate (goods):
If i2[0] = = ret:
Car.append (Goods[ret])
Print ( CAR)
If ret = =:
for i3 in car:
ZJ = 0
ZJ = i3[' price ' + ZJ
If ZJ > ZZC:
# Print (' Insufficient balance, please recharge ')
XZ = input (' Insufficient balance, select recharge input y, exit purchase input N: ')
if xz = = ' Y ':
JJ = int (input (' Please enter recharge amount: ')
Zzc = JJ + ZZC
else:
Print (' Welcome next visit ')
Else:
Print (' buy success ')
BR Eak



Shopping cart There are some questions behind the Python job please God help to perfect it, thank you ha

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.