美文网首页
2018-04-02 python实现购物

2018-04-02 python实现购物

作者: Kira_8768 | 来源:发表于2018-04-02 19:22 被阅读0次

    product_list = [

    ('Iphone',7000),

    ('Mac Pro',12000),

    ('Bycle',10000),

    ('StarBuck Latte',36),

    ('Wathc',16000),

    ('Alex Python',120),

    ]

    shopping_list = []

    salary =input("Please your salary:")

    if salary.isdigit():

    salary =int(salary)

    while True:

    for index,itemin enumerate(product_list):

    print(index,item)

    user_choice =input("Want to own it? :")

    if user_choice.isdigit():

    user_choice =int(user_choice)

    if user_choice =0:

    print(len(product_list))

    p_item = product_list[user_choice]

    if p_item[1]<=salary:

    shopping_list.append(p_item)

    salary -= p_item[1]

    print("Added %s into shopping cart,your current balance is \033[31:1m%s\033[0m" %(p_item,salary))

    else:

    print("\033 [31:1m Your balance is insufficient! \033 [0m")

    else:

    print("Without the goods!!!!")

    elif user_choice =="q":

    print("--------shoppint list---------")

    for pin shopping_list:

    print(p)

    print("Your current balance: ",salary)

    exit()

    else:

    print("Invalid option!!!!!")

    相关文章

      网友评论

          本文标题:2018-04-02 python实现购物

          本文链接:https://www.haomeiwen.com/subject/xegxhftx.html