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?
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()
Jennifer NordellTreehouse Staff
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!
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!!