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

Nicholas Anstis
Nicholas Anstis
2,095 Points

Python Basics challange

I can't figure it out. I don't know what i'm doing wrong.

Use input() to ask the user if they want to start the movie. If they answer anything other than "n" or "N", print "Enjoy the show!". Otherwise, call sys.exit(). You'll need to import the sys library.

firedoor.py
 play_again = input("Play again? Y/n ").lower()
            if play_again != 'n':
                return play(done=False)
            else:
                sys.exit()

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

You started off really well here! But there are a few things that are off. First, you forgot to import sys so it won't even know what sys.exit is. Secondly, the return statement shouldn't be there at all. You're supposed to print "Enjoy the show!". And third, you got a little carried away with your indentation which is causing indentation errors. Take a look at my solution:

import sys
play_again = input("Play again? Y/n ").lower()
if play_again != 'n':
  print("Enjoy the show!")
else:
  sys.exit()
Nicholas Anstis
Nicholas Anstis
2,095 Points

Thanks a lot. It's working and i understood my mistakes.

Was of great help

Shadow Skillz
Shadow Skillz
3,020 Points

Hi Jennifer thanks for the help as well. I was wondering is the .lower() function a nesecity im not to sure if thats my issues as well as other problems I'm having but would love your input

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

@christiansykes No, you don't absolutely have to have the .lower method, but for the challenge to pass you still have to take into account that the user should be able to enter either a lower case "n" or upper case "N" to quit. The resulting code would look like this:

import sys
play_again = input("Play again? Y/n ")
if play_again != 'n' && play_again != 'N':
  print("Enjoy the show!")
else:
  sys.exit()

In my opinion, it's better to use the .lower() method.

Hope this helps! :sparkles:

Shadow Skillz
Shadow Skillz
3,020 Points

Jennifer thank you so much for the clarification enjoy the rest of your day :-)