Python Python Basics (2015) Letter Game App Exiting

Mohammad Syed Raihaan
Mohammad Syed Raihaan
1,358 Points

Help with 'exiting' objective.

I don't understand what the problem is here. Can someone explain to me what's wrong and what this task expects me to do?

firedoor.py
import sys
a=str(input("Do you want to start the movie?"))
if a == "n" or "N":
    sys.exit()
else:
    print("Enjoy the show!")
Cooper Runstein
Cooper Runstein
11,780 Points

Right now your if statement is asking if a is equal to "n", or, if "N" is true. You're not actually asking if a == "N", only if it equals "n". The statement if "N" will return true, so your code is always ending at sys.exit(). To fix this, ask:

if a == "n" or a == "N":

1 Answer

Your statement always evaluates to true.

if a == "n" or "N": As "N" is not evaluated against anything Python seems to interpret always as True, so you will never get to False. If you go to python console in workspace you can confirm with bool() expressions to confirm results.

As a hint using the lower() or upper() function could be one way of simplifying the logic without using and/or for this challenge. The other way is making sure your "N" is compared to something.