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

This seems correct but TH says no

import sys

start_movie = input("Do you wnat to start the movie? Y/N: ")
if start_movie != "n" or start_movie != "N":
    print("Enjoy the show!")
else:
    sys.exit()

1 Answer

Steven Parker
Steven Parker
229,644 Points

Combining comparison expressions can be a bit tricky. Let's translate this into English:

if start_movie != "n" or start_movie != "N":

:point_right: "if start_movie is not the letter 'n', or it's not the letter 'N""...

So if start_movie contains any letter other than 'n', including 'N", this expression will be true because when you combine with "or" the whole expression is true when either side is true. And if the letter is 'n', the whole expression will be still true because it's not the letter 'N'. That means this expression will always be true for any possible letter.

The remedy is to combine inequality comparisons using and. That way both sides must be true for the whole expression to be true.

Ah ha. I thought about that before but was correcting something else AND forgot about it. Thanks very much.