Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5


Runtime error in python Program
16-04-2013, 08:48 AM
Post: #1
Runtime error in python Program
#This is a game to guess a random number.:scratchhead::scratchhead:

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
Reply



Forum Jump:


User(s) browsing this thread: 1 Guest(s)