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 trialMarcin Tokarzewski
3,487 PointsPython Basics / Letter Game / Code Challenge / "Exiting"
so, below code works to pass the challenge.... but it throw NameError: name 'what_was_inputted" is not defined. i am using v2.7.11 does it make any difference with v3.0 in this case?
import sys
movie = input("Do you want to start watching movie? Y/N")
for letter in movie:
if letter == "n" or letter == "N":
sys.exit()
else:
print("Enjoy the show!")
4 Answers
Marcin Tokarzewski
3,487 PointsOK, this is sorted now,
there is no problem with indentation, basically for python-2.7 ALWAYS use
raw_input
instead of
input
Jeremy Hill
29,567 PointsHere try this:
import sys
movie = input("Do you want to start watching movie? Y/N")
if movie.lower()=='n':
sys.exit()
else:
print("Enjoy the show!")
Marcin Tokarzewski
3,487 Pointsyour solution not to use "for" loop look better but still not working.
Jeremy Hill
29,567 PointsIt just needs to be properly indented- I just typed it, I didn't run it.
Jeremy Hill
29,567 PointsJeremy Hill
29,567 PointsI don't understand why you are using a for loop when the string holds one letter:
After the line of your movie declaration I would just do:
if movie.lower() == 'n':