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

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,850 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.