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 trialConnor Smith
1,005 PointsPython Basics Exiting Challenge: Why won't the code challenge accept my code?
Hello, I've recently started to learn the Python coding language, and have run into an issue with the Python Basics Exiting code challenge. My code seems to work as intended inside workspace, yet when i enter it as a solution in the challenge it is rejected. Please help me out~
challenge: https://teamtreehouse.com/library/python-basics/letter-game-app/exiting
The rejected coding I'm attempting to use as a solution is as follows:
Any help is greatly appreciated!
import sys
def play_movie():
while True:
start = input("Start movie? Y/n ").lower()
if start != 'n':
print("Enjoy the show!")
break
else:
sys.exit()
play_movie()
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsYou're going beyond what the challenge asks. There isn't a need to define a function or use a while loop. Commenting out the unnecessary lines and re-indent yields:
import sys
#def play_movie():
# while True:
start = input("Start movie? Y/n ").lower()
if start != 'n':
print("Enjoy the show!")
# break
else:
sys.exit()
#play_movie()
Post back if you need more help. Good luck!!!
Connor Smith
1,005 PointsConnor Smith
1,005 PointsThanks a lot for the quick response, I suppose it didn't occur to me the code challenges would be picky as to how the correct data was received, so long as it was received. I'll remember that~
Thanks again