-1

The code I have:

import random

guessesTaken = 0

print('Hello! What is your name?')
myName = input()

number = random.randint(1, 20)
print('Well, ' + myName + ', I am thinking of a number between 1 and 20.')

while guessesTaken < 5:
     print('Take a guess.')

     guess = input()
     guess = int(guess)
     guessesTaken = guessesTaken + 1
     guessesTaken = print('Thats a guess gone.')


     if guess < number:
         print('Your guess is too low.') 


     if guess > number:
         print('Your guess is too high.')

     if guess == number:
          print('You won at life!')
          break

     if guess == number:
        print('idk, ' + myName + '! You guessed my number in ' + guessesTaken + ' guesses!')
print('Again? Again.')

Need help with:

1.This error - Traceback (most recent call last):

  File "\\wbs-fs01\2013$\13CDyke\Guessing game.py", line 12, in <module>
    while guessesTaken < 5:
TypeError: unorderable types: NoneType() < int()

2.Need to fix it and display how many guesses you got the answer in.

1 Answers1

1

The problem is this line:

guessesTaken = print('Thats a guess gone.')

print returns None, so that's the value your variable gets. Remove the assignment and it'll work:

print('Thats a guess gone.')
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
  • Thanks that worked, also could you help me make it repeat upon inputting something like "Yes" or "No" – OBC Craig May 20 '16 at 12:19
  • @OBCCraig Stack Overflow has already helped a trillion other people do that. These two for example: http://stackoverflow.com/questions/12557376/python-repeat-program-while-true http://stackoverflow.com/questions/36273970/how-do-i-repeat-the-program/36274003 – Aran-Fey May 20 '16 at 13:19