Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

If/else statement works when I change a word, but not with the word I want.

Here is my code:

def slr():
    print("We recommend an SLR camera")
    while True:
        print("Do you currently own Nikon or Canon lenses? [Y/n]")
        user_lens = input("> ")
        if user_lens.lower() == "y":
            print("Nikon or Canon?")
            lens_quest = input("> ")
            if lens_quest.lower() == "nikon":
                print("Good news! Almost every current Nikon SLR is compatible!")
                break
            elif lens_quest.lower() == "canon":
                print("If your lenses were made before 1987,",
                "you will have to buy new lenses, in which case",
                "we recommend either a Nikon or Canon SLR.")
                break
            else:
                print("That is not a valid option. Enter Nikon or Canon.")
        elif user_lens.lower() == "n":
            print("Flip a coin: Canon and Nikon are both great.")
            break
        else:
            print("That is not a valid choice. Please enter Y or N.")

When I change "if lens_quest.lower() == "nikon" to "if lens_quest.lower() == "book", then the print statement prints. But when I keep it to "nikon" and enter nikon in the terminal, it says "That is not a valid option. Enter Nikon or Canon." If I answer with "NIKON" it also works. But, when I enter Canon, the desired print statement is printed. I'm a bit lost here.