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 trialtyler bucasas
2,453 Pointsexit challenge
my code keeps receiving a "Exception: EOF when reading a line" someone please let me know if I'm on the right track, thank you!
import sys
while True:
start = input("press 'n' or 'N' to quit")
if start.lower != 'n' or 'N':
print("Enjoy the show!")
else:
sys.exit()
2 Answers
Oszkár Fehér
Treehouse Project ReviewerHi Tyler. Actually you have the code what it passes the quiz. So after the import , the while loop it's not needed. The if statement it's almost ready If you call the lower() function, than you need to call the function with () ,and no need to pass in the 'N' to,
if start.lower() != 'n':
The lower() function makes the character small. What you wanted to write it would look like this
if start != 'n' or start != 'N':
But this is more writing it can be done in a different way
if start not in ['n', 'N']:
This line does what the previous line does. The rest of the code it's okey. So overall it should look something like this:
import sys
start = input("press 'n' or 'N' to quit")
if start.lower() != 'n':
print("Enjoy the show!")
else:
sys.exit()
You did well, the necessary code you made it. Keep up the good work and happy coding. I hope this will help you.
behar
10,799 PointsHey tyler! You have a couple of issues in your code. First is that your missing parenthesis after you use the lower method. Secondly is with the way your using the or operator. With these kinds of operators, you need to be more specfic. You currently doing something like this:
test = 5
if test == 5 or 6:
# Do something
But you should be doing it like this:
if test == 5 or test == 6:
# Do something
But seeing as your already using the .lower() method, you dont need to check if start == "N". It could never be that because your converting it to lowercase. Finally the challenge never asks you to make a while loop for this, so just delete that. In the end your code should look something like this:
import sys
start = input("press 'n' or 'N' to quit")
if start.lower() != "n":
print("Enjoy the show!")
else:
sys.exit()
Hope this helps!
behar
10,799 PointsToo slow..