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 Python Basics (2015) Letter Game App Exiting

Help with Exiting!

I have tried everything on this one, I feel my answer is legit! When I check if the answer is correct it keeps saying "Didn't get an exit from 'start_movie'." Is there something I may be missing?

firedoor.py
import sys

start_movie = input("Would you like to start another movie? Y/n. ")

if start_movie.lower() != "n" or "N":
    print("Enjoy the show!")
else:
    sys.exit()

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great. In fact, you've gone ahead and turned the user's answer to lowercase for them, so there is no need to check to see if it's "N". It never will be as you've already taken care of that. Simply erasing the or "N" will cause this to pass.

But there are a couple of reasons it's not passing right now. One is a syntax error and the other is a small logic flaw. When you do an evaluation you have to say each time what variable you're looking at and comparing. So if we took off the lower() we would have to compare start_movie both to "n" and "N".

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

But this is where the tiny logic flaw comes in. Remember, only one has to be true for the following block of code to run. There is nothing that we can put in here that will make this evaluate to false. If I enter "n", it will look at that and ask is it not equal to "n"? That is false, but then it moves on and asks is it not equal to "N"? That is true, and the code will run "Enjoy the show!". To fix this we must check that it is equal to neither and we do that with the and keyword.

if start_movie.lower() != "n" and start_movie != "N":

Hope this helps! :sparkles:

Ohhhhh I see now! Guess I was over-thinking a bit trying to keep the code clean... and I believe I copied "or" from the question and didn't think to change it to "and"... which indeed you're correct, would make it logical! ;)

But that really clears this up for me, so I know what to look out for in the future! :)

Thanks Jennifer! You're a rockstar!!