I am writing a program which is supposed to contain a way of informing the user that the input for one of the variables is not a string, if entered as a name by user.
E.g. program expects a user input of any string, and if it is a string which is contained within dictionary, it will print out its value, if not, it will print out an error message.
Your program isn't even getting to the part where it executes your
getage() method. It is failing far earlier.
input() instead of
JesusChrist is taken as the name of a variable because
input() evaluates what the user types as a Python expression.
JesusChrist is a legal Python variable name, it just hasn't been defined, so Python tells you that. And because it knows you can't do anything with a value that doesn't exist, it stops.
Now you could catch that error by wrapping your
input() in a
except block, but that's just trying to compensate for making the wrong decision in the first place. The right answer is to use
raw_input() to get input from your user and it will always be a string.