Validating user entered word



How does one validate that user entered a word and not a number or symbol?

Replace this line with your code.


user_input = raw_input("enter some text")
if user_input.isalpha():
    # code


Well, you can use the conditional flow like the if/else statement to filter whether the input of the user is an integer, a string, or a float. We can use the type already built function in python.

if type(what_the_user_input) == string:
    return "This is a string!"
    return "This is not a string!"