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

Moises Miguel
Moises Miguel
5,028 Points

Use input() to ask the user if they want to start the movie. If they answer anything other than "n" or "N", print "Enjo

i have no idea whats wrong

firedoor.py
import sys

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

if play != 'n':
    print("Enjoy the show!")
else:
    sys.exit()
Sam Baines
Sam Baines
4,315 Points

It looks like you are using a variable for 'play' in the if statement which isnt previously initialized - instead maybe it should be the variable 'start_movie' instead of 'play' - that would certainly make more sense as its the only thing to have any input which could be used in the if statement.

Also you may need to make the condition for the if statement be != 'n' || 'N': - this then accounts for both in the challenge title.

Hopefully this helps.

1 Answer

Good attempt! You supposed to use the same variable, though. Try using the variable start_movie instead of play. Also, the condition should be if start_movie is not "n" AND also not "N", not if start_move is not "n". Try this:

import sys

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

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

Also, to make the code a little less, it's a good idea to change start_move to lowercase letters then check if that is not "n". The lowercase form of "n" and "N" both are "n", so this should also work :smile: This is the code that I'd put into the code challenge (this doesn't mean the code above this text doesn't work :smile: both of these will work):

import sys

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

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

I hope this helps and good luck coding! ~Alex

:)