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

I get an error when I want to play again

I'm using the same code as the one in the video and the download file. When I guess the number and I'm asked if I want to play again, I get this error, both entering y or n:

Traceback (most recent call last): File "number_game.py", line 34, in <module> game() File "number_game.py", line 28, in game play_again = input("Do you want to play again? Y/n") File "<string>", line 1, in <module> NameError: name 'n' is not defined

Can anybody help me solve this issue, please?

3 Answers

Jeff Wilton
Jeff Wilton
16,646 Points

Did you forget quotes around the 'n' on this line?

if play_again.lower() != 'n'

No I did not forgot any quote. I also tried with "n" but I get the same error. As I said, it's the exact same code as the one given by Kenneth Love.

Solved.