Python Merchandise Shopping Cart

Source: Internet
Author: User

1shopping_cart=[]2 3commodity=[("iphone", 5000),4("Bike", 200),5(" Book", 100),6("Computer", 3000),7("Car", 10000),8 ]9Salary=input ("Please input your salary:")Ten  One #Print (commodity) A ifsalary.isdigit (): -salary=Int (Salary) -      whileTrue: the          forIndex,iteminchEnumerate (commodity): -             Print(Index,item) -Use_choice = input ("choose want to buy commodity num:") -         ifuse_choice.isdigit (): +Use_choice=Int (use_choice) -             ifUse_choice<len (commodity) anduse_choice>=0: +p_item=Commodity[use_choice] A                 #print (p_item[1]) at                 ifp_item[1]<=Salary: - shopping_cart.append (P_item) -Salary-=p_item[1] -                     Print("Shopping_cart added%s, your current balance is \033[31;1m%s \033[0m"%(p_item,salary)) -                 Else : -                     Print("\033[41;1m Insufficient balance, please re-select%s \033[0m"%salary) in             Else: -                 Print("Please iput correct product code \033[31;1m%s \033[0m"%Use_choice) to         elifuse_choice=="Q" : +             Print("--------Shopping list---------") -              forIinchShopping_cart: the                 Print(i) *Exit"successful exit of purchased items") $         Else:Panax Notoginseng             Print("Please input Correct commodinty num \033[31;1m%s \033[0m"%Use_choice) - Else: the     Print("\033[31;1mplease input Correct salary%s \033[0m"%salary)

Python Merchandise Shopping Cart

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.