Question #172914

Write a program that asks the user for a number between 10 and 30 inclusive and will validate, that is test, the input. It should repeatedly ask the user for this number until the input is within the valid range.


Expert's answer

while True:
    number = int(input('Enter a number between 10 and 30 with 10 and 30 inclusive'))
    if number < 10 or number > 30:
        print('Enter correct number')
    else:
        print(number)
        break
LATEST TUTORIALS
APPROVED BY CLIENTS