You can do this using type or insinstance of python builtin module, like,
if type(user_input) is int:
# your code
type returns the type of the obect. Or using insinstance,
if isinstance(user_input, int):
# your code
isinstance return True if the object is instance of a class or it’s subclass.
Now, in your code you are already casting the user_input an int in the first line. So there is no point to check if user_input is int or str. The programme will also raise an error if you give an input other than digit.
8
solved What function allows to ask wether a variable is an integer inside an if statement [closed]