pythonのカートversion 2.0


#author:zhouyu
produce_list = [
    ('Watch'
,1000),
    ('Telephone',6500),
    ('Television',4500),
    ('refrigerate',2300),
    ('washer',680),
    ('compute',5500)
]
#

shopping_list = []
#
salary = input("Please input your salary: ")
#isdigit salary , True
if salary.isdigit():
#
    salary = int(salary)
    while True:
# ,enumerate , 。
        for index,i in enumerate(produce_list):
           
print(index,i)
#
        user_choose = input("Please input the number of what do you want: ")
        if
user_choose.isdigit():
           
user_choose = int(user_choose)
#len 。
            if user_choose >= 0 and user_choose < len(produce_list):
# ,
                p_item = produce_list[user_choose]
#
                if p_item[1] <= salary:
# shopping_list
                    shopping_list.append(p_item)
# ,
                    salary -= p_item[1]
                   
print("Add %s into shopping cart,and your balance is \033[31;1m%d\033[0m" %(p_item[0],salary))
#
                else:
                   
print("\033[41;1myour balance is not enough,get out there!!!\033[0m")
# 0 len(produce_list)
            else:
               
print("\033[41;1mthe produce is not exists!!!\033[0m")
# q quit,
        elif user_choose == 'q':
           
print("----------product list -----------")
            for
i in shopping_list:
               
print(i)
           
print("your balance is ", salary)
           
exit(1)
#
        else:
           
print("Invali number !!!")