I am trying to make a guess the number game and I have a problem with a piece of code that is meant to stop the player from inputting a letter instead of a number.
I am trying to get a int from a player input and i can do that but when I input nothing and hit enter or a letter the value error doesn't catch it and it breaks my code
try:
player_guess = input("\n\n\n{} what is your guess?\n".format(player_name)) #askes the player for a guess
player_guess = int(player_guess)
except ValueError as verr:
print("please enter a number")
except Exception as ex:# do job to handle: Exception occurred while converting to int
print("{} please only input a number.".format(player_name))
time.sleep(2)
print("\n\n\n")
print(player_guess)
if player_guess < number_real: # if the number is lower than the real number run this
the last line of code is the one that breaks because I'm trying to use a string with an int.