ELIF语句无法正常工作?

时间:2019-07-11 02:29:24

标签: python python-3.x

如果只有一个elif,则elif语句是唯一有效的意思,但是我需要多个,这只需要第一个就可以了。

我已经删除了两个elif语句之一,以检查它们是否存在错误,但是当它们单独运行时它们可以正常工作。

    ask = input("How may I help you?")
    if ask == "":
        print("Thats Not A Valid Question")
    elif ask == "Multiply" or "multiply" or "*" or "Product" or "product":
        ask = input("What numbers would you like me to multiply?")
        numbers = ask.split();
        numbers = turnListToInt(numbers);
        print(operationList(numbers,1));
    elif ask  == "add" or "Add" or "ADD" or "+":
        ask = input("What numbers would you like me to add?");
        numbers = ask.split();
        numbers = turnListToInt(numbers);
        print(operationList(numbers,3));

如果我说“添加”,则应转到添加代码块。

0 个答案:

没有答案
相关问题