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 trialBarry Lam
14,406 PointsChallenge Tast 1 of 1 for Python Basics Last Chapter
Trying to exit the start_movie function but not getting the correct result
import sys
def start_movie():
arg = input("Do you want to start a movie?")
if arg == "n" or arg == "N":
print("Bye")
sys.exit()
else:
print("Enjoy the show!")
any help would be appreciated
3 Answers
Bart Bruneel
27,212 PointsHey Barry,
there is no need to wrap the code in a function. If you delete the def start_a_movie and properly indent everything it works.
Barry Lam
14,406 Points@Bart
Thanks for the help, i'm really surprise you don't put it in a function. Anyways much appreciated.
martin, i was expecting it exit the program but every time it was wrong answer, i had tested the function outside of the workspace envirnoment and it worked.
Bart Bruneel
27,212 PointsOne of the keys to solving the code challenges is not doing any more work than the challenges ask. You would definitely put the code inside of a function if you would write a real-world script. However, the code challenge is also checked by some code that has no way of knowing how you decide to name your function and thus no way of calling it to check if what inside of it is correct.
Martin Cornejo Saavedra
18,132 PointsMartin Cornejo Saavedra
18,132 PointsWhat is your current result and what do you expect?