Dec-13-2018, 11:39 PM
I also use mostly try/except way proposed by @Gribouillis.
But look at the string methods isdecimal, isdigit, isnumeric.
But look at the string methods isdecimal, isdigit, isnumeric.
answer = input("Enter something: ") if answer.isnumeric(): number = int(answer) else: # do something else.