我被困在一个程序上

时间:2018-12-11 10:29:57

标签: python python-3.x

first = input("""Hello, welcome to Yusuf's pizza shop
This is the menu, all sizes are available
PEPPERONI PIZZA
CHICKEN PIZZA
VEG PIZZA
MUSHROOM PIZZA
PIZZA PIE
CHEESE PIZZA
How can i help you.

""")
first = first.lower()
chat = first.split()

if "pepperoni" in chat and "small" or "regular" in chat:
    order = "small pepperoni pizza"
    print("Do you want anything else?")
    anyelse = input()
    if "no" in anyelse:
        print("Ok, then here is your order - " + order + " It will be 
delivered to your house soon")
        input()
    elif "yes" in anyelse:
        order2 = input("""What else do you want?
         """)
        order2 = order2.lower()
        if "coke" in order2 or "chicken pizza" in order2 or "veg pizza" in 
order2 or "mushroom pizza" in order2 or "pizza pie" in order2 or "cheese 
pizza" in order2 or "pepperoni pizza" in order2:
            print("Ok, then here is your order - " + order + " and " + 
order2 + " it will be delivered to your house soon")
            input()


if "pepperoni" in chat and "medium" in chat:
    order = "medium pepperoni pizza"
    print("Do you want anything else?")
    anyelse = input()
    if "no" in anyelse:
        print("Ok, then here is your order - " + order + " It will be 
delivered to your house soon")
        input()
    elif "yes" in anyelse:
        order2 = input("""What else do you want?
         """)
        order2 = order2.lower()
        if "coke" in order2 or "chicken pizza" in order2 or "veg pizza" in 
order2 or "mushroom pizza" in order2 or "pizza pie" in order2 or "cheese 
pizza" in order2 or "pepperoni pizza" in order2:
            print("Ok, then here is your order - " + order + " and " + 
order2 + " it will be delivered to your house soon")
            input()

if "pepperoni" in chat and "large" in chat:
    order = "large pepperoni pizza"
    print("Do you want anything else?")
    anyelse = input()
    if "no" in anyelse:
        print("Ok, then here is your order - " + order + " It will be 
delivered to your house soon")
        input()
    elif "yes" in anyelse:
        order2 = input("""What else do you want?
         """)
        if "coke" in order2 or "chicken pizza" in order2 or "veg pizza" in 
order2 or "mushroom pizza" in order2 or "pizza pie" in order2 or "cheese 
pizza" in order2 or "pepperoni pizza" in order2:
            lower.order2()
            print("Ok, then here is your order - " + order + " and " + 
order2 +  " it will be delivered to your house soon")
            input()

正如您在此问题中看到的那样,由于我粘贴了代码,因此代码有些混乱,因此无论如何请尝试阅读或粘贴在记事本中并阅读。好的,所以此程序有一个名为order的变量,每当我输入“大意大利辣香肠比萨饼”之类的值时,它将其存储为小意大利辣香肠比萨饼,请帮帮我。

1 个答案:

答案 0 :(得分:1)

将第15行更改为

if "pepperoni" in chat and "small" or "regular" in chat:

if "pepperoni" in chat and ("small" in chat or "regular" in chat):

您不能写foo or bar in foobar,而必须写foo in foobar or bar in foobar。前者会将foo评估为True,然后剩下True or bar in foobar,每次都会得到True