I have an exercise from the course I study from, but it gives me an error:
"Guess a number between 1 and 100: Traceback (most recent call last):
  File "main.py", line 15, in <module>
    guess = input("Guess a number between 1 and 100: ")
EOFError: EOF when reading a line"
- How can I fix that ?
- Have I done the exercise in a right way ? And just to make sure - the "break" breaks the while, right ?
# Write a program that picks a random integer from 1 to 100, and has players guess the number. The rules are:
# If a player's guess is less than 1 or greater than 100, say "OUT OF BOUNDS"
# On a player's first turn, if their guess is #within 10 of the number, return "WARM!"
# further than 10 away from the number, return "COLD!"
# On all subsequent turns, if a guess is
# closer to the number than the previous guess return "WARMER!"
# farther from the number than the previous guess, return "COLDER!"
# When the player's guess equals the number, tell them they've guessed correctly and how many guesses it took!
from random import randint
random_number = randint(1,100)
guess_count = 0
guess = input("Guess a number between 1 and 100: ")
while False:
    guess_count += 1
    if guess_count == 1:
        if guess == random_number:
            print(f'Congratulations! You have chose the correct number after the first try!')
            break
        else:
            if abs(guess-random_number) < 11:
                print("WARM!")
            else:
                print("COLD!")
    else:
        old_guess = guess
        guess = input("Guess another number between 1 and 100: ")
        if guess == random_number:
            print(f'Congratulations! You have chose the correct number after {guess_count} tries!')
            break
        elif abs(random_number - guess) < abs(random_number - old_guess):
            print('WARMER!')
        elif abs(random_number - guess) > abs(random_number - old_guess):
            print('COLDER!')
input("Press anywhere to exit ")
 
     
    