Validating user entered word

python

#1



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


Replace this line with your code.


#2

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

#3

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!"
else:
    return "This is not a string!"