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

Richard Farr
Richard Farr
4,857 Points

I'm not getting an exit... but why?

baffled here

firedoor.py
import sys

start_movie = input("Do you want to start the movie?")

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

3 Answers

Hi Richard,

Try tracing through the code if the user typed 'N'

The first condition will be true because 'N' is not equal to 'n' and because you used or the whole thing will be true and you'll get "Enjoy the show!"

So you have to make sure that it's not 'n' and it's not 'N'

Richard Farr
Richard Farr
4,857 Points

got it... changed or to an and.

thank you

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

one solution would be to use the in keyword with a list, such as: if myVar not in [ 'answer1', 'answer2' ]. the if block will get executed if myVar is not in the list, and the else block will be executed if myVar IS in the list.

Richard Farr
Richard Farr
4,857 Points

I tried...

import sys

start_movie = input("Do you want to start the movie?")

if start_movie not in ["n","N"]: print("Enjoy the show!") else: sys.exit(0)

& still having issues.

any tips?

thank you