num = 0 while True: try: v = input("Enter a number: ") num = int(v) break except Exception as ex: # if v is a non-numeric string, the type of exception is "ValueError" print('Input error ' + v + ' exception type ' + type(ex).__name__) print('value of input ' + str(num))