I am trying to print the type of the value that is given as input in the try block when an exception is raised so that it gives a clear picture to the user as to what input is actually given and what needs to be given instead using the following code snippet in Python -
a = None
try:
a = int(input('Enter a number'))
print(a)
except ValueError:
print('Control waited for Integer , but got a {}'.format(type(a)))
But unable to access the type of variable 'a' in the except block. For example: when the user provides the input as True , I'd want the user to know that the control waited for integer but it received a boolean instead. in python. locals() function did not help. Any insights ?