Ok, so, I'm trying to make a "guess the number" game, a game where you say a number and the other player say "Lower" or "Higher" depending on your answer, and when you guess the number correctly you win.
Maybe this was already answered, but I can't figure out what's wrong.
I don't get it, if inside the function you call itself, it is supposed to run itself again, right?
Not sure if it's helpful but I'm using Python 3.
number = 897
attempts = 0
def guess():
guess = input("Number: ")
guess = int(guess)
global attempts
if guess > number:
print("It's lower.")
attempts = attempts + 1
guess()
elif guess < number:
print("It's higher.")
attempts = attempts + 1
guess()
else:
print("Correct! The number was " + str(number) + "!")
print("It took you " + str(attempts) + "!"),
print("I'm thinking of a number, guess it!")
guess()