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 trialNicholas Anstis
2,095 PointsPython 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.
play_again = input("Play again? Y/n ").lower()
if play_again != 'n':
return play(done=False)
else:
sys.exit()
1 Answer
Jennifer Nordell
Treehouse TeacherYou 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
2,095 PointsNicholas Anstis
2,095 PointsThanks a lot. It's working and i understood my mistakes.
Was of great help
Shadow Skillz
3,020 PointsShadow Skillz
3,020 PointsHi 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
Treehouse TeacherJennifer 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:In my opinion, it's better to use the
.lower()
method.Hope this helps!
Shadow Skillz
3,020 PointsShadow Skillz
3,020 PointsJennifer thank you so much for the clarification enjoy the rest of your day :-)