Q:

Python How to check if user input is a string?

My first question on here...
I want to know how to check if the user input is a string.  If it is not a message should appear.  Otherwise the answer should be accepted.  Here is what I have (I am looking for the simplest fix please):
try:
    name=str(raw_input("What is your name? "))
except:
    print("Your name must consist of letters only")
else:
    print("Thank you for entering your name.")

A:

str.isalpha() checks if all characters in the string are alphabetic and there is at least one character. So
name=str(raw_input("What is your name? "))
if not name.isalpha():
    print("Your name must consist of letters only")
else:
    print("Thank you for entering your name.")

However this will not work if name is "Homer Simpson" (with a space) which is valid input for name.
And don't you forget this!!!

