So I'm new to python and went trough a tutorial to write a hangman game in python 2.7 on my new pi. Well, anyway I liked the code and everything, and it ran fine but then I wanted to add something to make it ask ,"if you wanted to continue playing", and I did a lot of research and talked on some chat rooms about it and came up with/found this script to exit:

```
while keep_playing == False:
user = raw_input("\n\tShall we play another game? [y|n] ")
again = "yes".startswith(user.strip().lower())
if again:
    keep_playing = True
if not again:
    break

raw_input ("\n\n\nPress enter to exit")

```

but I get this error:

```
Traceback (most recent call last):
File "/home/pi/Desktop/Scripts/scrappy/ls/ls/hangman3.py", line 40, in <module>
   while keep_playing == False:
NameError: name 'keep_playing' is not defined

```

when its ran with this script

```
import random
import urllib

print 'time to play hangman'
   animals = urllib.urlopen('http://davidbau.com/data/animals').read().split()
secret = random.choice(animals)
guesses = 'aeiou'
turns = 5

while turns > 0:
missed = 0
for letter in secret:
  if letter in guesses:
    print letter,
  else:
    print '_',
    missed += 1

print

 if missed == 0:
   print 'You win!'
    break

 guess = raw_input('guess a letter: ')
 guesses += guess

 if guess not in secret:
    turns -= 1
    print 'Nope.'
    print turns, 'more turns'
    if turns < 5: print '   O   '
    if turns < 4: print ' \_|_/ '
    if turns < 3: print '   |   '
    if turns < 2: print '  / \  '
    if turns < 1: print ' d   b '
    if turns == 0:
      print 'The answer is', secret

while keep_playing == False:
user = raw_input("\n\tShall we play another game? [y|n] ")
again = "yes".startswith(user.strip().lower())
if again:
    keep_playing = True
if not again:
    break

raw_input ("\n\n\nPress enter to exit")

```

Can anyone help me?
\*\*\*\*edit\*\*\*\*\*
someone can close this tread using the tips provided i have solved my problem this is the final code

```
import random
import urllib

animals = urllib.urlopen('http://davidbau.com/data/animals').read().split()

while True:

print 'time to play hangman'
secret = random.choice(animals)
guesses = 'aeiou'
turns = 5

while turns > 0:
    missed = 0
    for letter in secret:
        if letter in guesses:
            print letter,
        else:
            print '_',
            missed += 1

    print

    if missed == 0:
        print 'You win!'
        break

    guess = raw_input('guess a letter: ')
    guesses += guess

    if guess not in secret:
        turns -= 1
        print 'Nope.'
        print turns, 'more turns'
        if turns < 5: print '   O   '
        if turns < 4: print ' \_|_/ '
        if turns < 3: print '   |   '
        if turns < 2: print '  / \  '
        if turns < 1: print ' d   b '
        if turns == 0:
            print 'The answer is', secret
            break

user = raw_input("\n\tShall we play another game? [y|n] ")
again = "yes".startswith(user.strip().lower())
if not again:
    raw_input ("\n\n\nPress enter to exit")
    break

```