Im trying to make it so the warmer/colder text appears after input, but it doesn't print until the end of the program?
I think it has something to do with the elif statement? i keep having trouble with those in other projects (had to put hangman on the backburner because of it.) I'm trying to make a program where you guess the a number between 1-50 but i just don't know how to rectify this problem?
import random
print("Welcome to the number guessing game!")
print("")
guesses_allowed = 10
number = random.randint(1, 50)
guess = ""
for i in range(guesses_allowed):
guess_number = int(input("Please guess a number between 1 and 50: "))
guess = int(guess_number)
if guess == number:
print("Congrats you guessed correctly")
elif guess < number:
print("number is higher.")
else:
print("number is lower.")
if (i == guesses_allowed - 1):
print("Sorry, have run out of guesses")
if abs(guess - number) <= 10:
print("You're warm!")
elif abs(guess - number) <= 20:
print("You're getting warmer.")
elif abs(guess - number) <= 30:
print("You're cold")
else:
print("You're freezing")