Shoping shopping (learned the old boy video written)

Source: Internet
Author: User

Import syslog
Import Sys

product=[' Apple ', ' coffee ', ' pc ', ' Rebot ', ' clothes ', ' licai '] #创建数组

PRICE=[4999,30,8000,100000,1000,500] #创建数组

Qingdan = [] #创建数组

While True:

Gongz=int (raw_input (' \033[33;1mplease input you gz:\033[0m '). Strip ())


#输入工资, not numeric exception handling

#except ValueError:
Except ValueError:
Print "error:you must input a num"

While True:

print ' \033[35;1mplease looking for caidan\033[0m ' #输出你的菜单

For line in product:


Print "\033[32;1m%s\t%s\033[0m"% (Line,price[product.index (line)])


If Gongz < min (price): #判断是否购买的起

Print "\033[34;1m didn ' t buy this is buy\033[0m"

Print "\033[34;1m", Qingdan, "\033[0m"


Sys.exit ()


Goumai = Raw_input (' \033[32;1m you need shopping,please take it\033[0m ')


If goumai== ' exit ':

#exit exit Judgment

Print "\033[35;1m you buy", Qingdan, "\033[0m"

Sys.exit ()

If Goumai in product:

If Gongz < Price[product.index (Goumai)]:


Print "\033[31;1myou can ' t buy", Goumai, "Youhave", Gongz, "\033[0m"




Qingdan.append (Goumai)


Gongz = Gongz-price[product.index (Goumai)]


Print "\033[35;1m you buy", Qingdan, "We have", Gongz, "\033[0m"

print "\033[31;1mdon ' t hava this wp,you has", Gongz, "\033[0m"


This article is from the "Once Operations" blog, please be sure to keep this source

Shoping shopping (learned the old boy video written)

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: 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.