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 trialRichard Farr
4,857 PointsI'm not getting an exit... but why?
baffled here
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
Jason Anello
Courses Plus Student 94,610 PointsHi 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'
james south
Front End Web Development Techdegree Graduate 33,271 Pointsone 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
4,857 PointsI 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
james south
Front End Web Development Techdegree Graduate 33,271 Pointstake the 0 out of the call to sys.exit and it works. just passed it with sys.exit().
Richard Farr
4,857 PointsRichard Farr
4,857 Pointsgot it... changed or to an and.
thank you