Python Simple shopping Cart small code

Source: Internet
Author: User

1 #-*-coding:utf-8-*-2 #@Time: 2018-05-31 14:563 #@Author: Superman4 #@Email: [Email protected]5 #@File: Shopping cart Little Practice6 #@Software: Pycharm7 8 9Goods_list = [Ten['Apple', 30], One['Car', 80000], A['Tesla', 999999], -['Computer', 20000] - ] theShopping_car=[] -Money = input ('Please enter your purchase amount:') - ifmoney.isdigit (): -money=Int (money) +      whileTrue: -          forI,oinchEnumerate (goods_list): +             Print(I,o) Agoods_id = input ('Please enter the purchased product serial number [exit Q]:') at         ifgoods_id.isdigit (): -Goods_id=Int (goods_id) -             ifGoods_id>=0 andgoods_id<Len (goods_list): -Goods_price=goods_list[goods_id] -Money=money-goods_price[1] -                 ifMoney>0: in                     Print(Goods_price) - shopping_car.append (Goods_price) to                 Else: +                     Print('Insufficient Balance') -                      Break the             Else: *                 Print('Product number does not exist') $         elifgoods_id = ='Q':Panax Notoginseng             Print('-----------------------Buy the following items-------------------------------') -              forIinchShopping_car: the                 Print(i) +             Print('remaining%s dollars'%Money ) A              Break the Else: +             Print('Please enter a valid character!')

Python Simple shopping Cart small code

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.