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

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

Im attempting to get it to print if they dont answer with an n or N, or quit if they do. I keep getting a syntax error on line 3 and on my own at home projects, when ever i attempt to use something like this to replay a game i made, it never seems to work!

firedoor.py
import sys
choice = input("Would you like to start the movie?: ".lower())
    if choice != "n" or "N":
        print("Enjoy the show!")
    else:
        sys.exit()

2 Answers

Why would you need or != "N"? You put .lower() in the input, so any input is going to be lowercased. Thus your if statement will work fine if you just say

if choice != "n":

even if i take out .lower it dose not work

But the challenge asks you to put lower()

I also want to address the error the python is giving to you. When you look at your line 3, where your if statement happens, That code and below should not be indented, but your codes are indented.

So first I would unindent the code from line 3 and below.

As for the future reference, when you want to write or in an if statement you can't write it like this.

if choice != "n" or "N":

it needs to be

if choice != "n" or choice != "N":

# or you cant use elif statement

if choice != "n":
   pass
elif choice != "N":
   pass

I still cant seem to figure it out

import sys
answer = input("Start the movie, Y/n?: ".lower())
if answer != "n":
    print("Enjoy the show!")
else:
    sys.exit()

Okay, The issue was in line 2. You ended the bracket at the wrong place.

choice = input("Would you like to start the movie?: ".lower())

What this will do is make the entire string "Would you like to start the movie?" all into lower case, but that is not what you want.

You want the input of the person to be lower thus, you write .lower() after the input("Would you like to start the movie?: ").lower()

What you want to write ultimately is these codes.

Try

import sys
choice = input("Would you like to start the movie?: ").lower()
if choice != "n":
    print("Enjoy the show!")
else:
    sys.exit()

taejooncho why does there need to be a

.lower()

why can't we just have

if answer != "n" or answer != "N":