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 trial

Python Python Basics (2015) Number Game App Number Game Refinement

Cant figure out my issue with restarting game, after it has ended!

With the following code block (hopefully it sent, im quite new and cant seem to figure out how to post my code) every time i type "n" it will run the print("Bye!") but if i type anything other then n it wont play game()

play_again = input("Do you want to play again? Y/n: ")
    if play_again.lower() != 'n':
        game()
    else:
        print("Bye!")

2 Answers

Maybe "if play_again.lower()" should be starting right under "play_again = …"

Under the same column.

Not indented.

i believe you are correct, il check up on it and come back!

Jonathan Whelchel
Jonathan Whelchel
2,096 Points

I am having a different issue. Whenever I type in Y or n, I get an error saying Y or n is not defined.

play_again = input("Do you want to play again? Y/n ")

if play_again != 'n':
    game()

else: 
    print("Bye!")

Jonathan probably because you are not changing the input to a lower case - .lower()

Jonathan Whelchel
Jonathan Whelchel
2,096 Points

if play_again.lower() != 'n':

this is what I have written. but the user has to put in the quotes as well. why?