I'm trying to create a guessing game. I want it so that it uses a while loop and changes the input message after the first one. I put together this piece of code but it doesn't evaluate correctly (it will say 9 is too high and say that 1 is too high and then the answer will be 18... things like that) and for the life of me can't figure out why.
import random
number = str(random.randint(1,20))
name = input("What is your name? ")
guess = input("Hello %s! I am thinking of a number between 1 and 20. What number am I thinking of? " % name)
while (guess != number):
if guess > number:
guess = input("Too High! Guess again: ")
elif guess < number:
guess = input("Too Low! Guess again: ")
print("Congratulations! You guessed it correctly!")