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

siva sanka
siva sanka
4,099 Points

please help me regarding this

import sys movie= input('please enter any thing to start or N/n to to exit') if movie == 'n' or 'N': sys.exit() else: print("Enjoy the show!")

firedoor.py
import sys
movie= input('please enter any thing to start or N/n to to exit')
if movie == 'n' or 'N':
    sys.exit()
else:
    print("Enjoy the show!")

1 Answer

Farid Wilhelm Zimmermann
Farid Wilhelm Zimmermann
16,753 Points

I am not sure I understand what your issue is, but I think you wanted to call sys.exit() only if your input evaluates to 'n' or to 'N'. You have to declare it like this:

if movie == 'n' or movie == 'N':
    sys.exit()

The way you currently defined your condition, the interpreter will read it as follows

if movie == 'n' or 'N' == TRUE:
    sys.exit()

This will always evaluate to TRUE.

When you are using boolean operators and are comparing values, you have to make that comparison on both sides of the operator.