#This is a game to guess a random number.

import random

guessTaken = 0

print(“Hello! What’s your name kid”)

myName = input()

number = random.randint(1,20)

print("Well, " + myName + “, I’m thinking of a number between 1 and 20.”)

while guessTaken < 6:

print(“Take a guess.”)

guess = input()

guess = int(guess)

guessTaken = guessTaken + 1

if guess < number:

print(“You guessed a little bit too low.”)

if guess > number:

print(“You guessed a little too high.”)

if guess == number:

break

if guess == number:

guessTaken = str(guessTaken)

print("Well done " + myName + “! You guessed the number in " + guessTaken + " guesses!”)

if guess != number:

number = str(number)

print("No dice kid. I was thinking of this number: " + number)

This is the error I get:

Name error: Name ‘s’ is not defined.

Live Project Training

I changed input() to raw_input. I think there may have been an indenting issue also. Anyway this works.

#This is a game to guess a random number.

import random

def main():

guessTaken = 0

myName = “”

print(“Hello! What’s your name kid”)

myName = raw_input(‘’)

number = random.randint(1,20)

print("Well, " + myName + “, I’m thinking of a number between 1 and 20.”)

while guessTaken < 6:

print(“Take a guess.”)

guess = input()

guess = int(guess)

```
guessTaken = guessTaken + 1
if guess < number:
print("You guessed a little bit too low.")
if guess > number:
print("You guessed a little too high.")
if guess == number:
break
```

if guess == number:

guessTaken = str(guessTaken)

print("Well done " + myName + “! You guessed the number in " + guessTaken + " guesses!”)

if guess != number:

number = str(number)

print("No dice kid. I was thinking of this number: " + number)

if **name** == ‘**main**’:

main()

please reformat your code, and use the code blocks in the editor