lundi 27 mai 2019

Basic nested if in Python

I am starting with python and facing a basic issue with this nesting exercise:

bird_names="eagle", "pigeon", "colibri", "seagull"

bird_guess=input("Guess the bird: ")

if bird_guess in bird_names == False:
    print("Try again")
    bird_guess2=input("Guess the Bird: ")   

    if bird_guess2 in birds == False:
        print("Try again")
        bird_guess3=input("Guess the Bird: ") 

        if bird_guess3 in birds == False:
            print("Sorry out of tries")     
        else:
            print("Yes 3rd try")
    else:
        print("Yes 2rd try")
else:
    print("Great, 1st try")

When I run it and assing to bird_guess the value d for example, the code outputs direct Great, 1st try instead of going through all the other if statemnts.

Any idea where is my error?

Aucun commentaire:

Enregistrer un commentaire