You could use a try block.
import random RNumber = random.randint(1, 10) while True: try: user_input = int(input('Guess a number\n>> ')) except ValueError: print('Please use only whole numbers') continue else: if user_input > RNumber: print('Number is to high') elif user_input < RNumber: print('Number is too low') else: print(f'Congradulation! You guessed the number {RNumber}') RNumber = random.randint(1,10)
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags