Write a Python program to input a number, if it is not a number generate an error message

code :-

while True:
    try:
        a = int(input("Input a number: "))
        break
    except ValueError:
        print("\nThis is not a number. Try again...")
        print()
		
output 1:-

Input a number: 12
>>> 

output 2:-

Input a number: 

This is not a number. Try again...

Input a number: 


Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post