I've just started learning Python and have constructed a little guessing game. It works but I would like to add a statement that if inputted number is out of range 1-10 there will be an error... Could you help or give me a hint? I suppose I should use nested if/else statement but not sure where:
import random as r
rand_num = r.randrange(1, 10)
odp = 0
i = 0
print("Guess the number from range 1-10")
while True:
i += 1
odp = int(input("Input number: "))
if (rand_num < odp):
print("Selected number is lower than you had inputted...")
elif (rand_num > odp):
print("Selected number is higher than you had inputted...")
elif (rand_num == odp):
break
print("Congrats! You have guessed the number after ", i, " tries")