Oct-29-2018, 02:40 AM
import random
randomNumber = random.randint(1, 5)
while True:
input_value = input("Please guess a number between 1 and 5: ")
try:
guess = int(input_value)
except ValueError:
print("{guess} is not a number, please enter a number!".format(guess=input_value))
continue
else:
break
if guess < 1:
print("It has to be a number between 1 and 5.")
continue
else:
break
if guess > 5:
print("It has to be a number between 1 and 5.")
continue
else:
break
if guess == (1, 5):
if guess == randomNumber:
print("Congrats! {guess} was the correct number!".format(guess=input_value))
else:
print("Sorry, {guess} was not the correct number.".format(guess=input_value))Seems to automatically skip over guess < 1 and guess > 5 after the first break?
