Read lines until a valid whole number between 1 and 10 is entered, explaining each rejection.
while True:
text = input()
try:
n = int(text)
except ValueError:
print(f"{text!r} is not a whole number")
continue
if 1 <= n <= 10:
break
print(f"{n} is outside 1-10")
print("Accepted:", n)
'seven' is not a whole number '7.5' is not a whole number 42 is outside 1-10 Accepted: 7
The try block holds only the conversion; the range check is ordinary logic after it.