Python Python Basics (2015) Letter Game App Exiting

tyler bucasas
tyler bucasas
2,453 Points

exit 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!

firedoor.py
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
Oszkár Fehér
Treehouse Project Reviewer

Hi 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.

Hey 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!

Too slow..