Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
220,416 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.