mardi 29 décembre 2020

Make if elif else to move onto next elif

Suppose there is this code

statement = input()

if "book" not in statement:
    if "what" in statement:
        print("something")
    # else: 
        # something here which will make the program to move onto the next elif
    
elif "bag" in statement:
    print("anything")
elif "book" in statement:
    print("everything")

now if we execute the code, and there's no "book" in statement but there is "bag" it won't print anything. I know I can add and in the first condition but my real code is more complicated. Please tell me a way so that it will move on to the next elif, if "what" is not in statement

Aucun commentaire:

Enregistrer un commentaire