How do I use isalpha( )?



How do I use isalpha( )?


isalpha() is a method that can be used on any string - whether it be a variable holding a string, or a string by itself, or a string returned from another method. We use it in this PygLatin translator to check if the user of our program inputs anything other than alphabetical characters, A-Z a-z.
To make use of it, we simply attach it to the end of a string we want to check for that condition - being solely alphabetical. Like this:

my_string = “Not 4lphabet1cal”
if my_string.isalpha():
    print “isalpha() returned True; the string was entirely alphabetical!”
    print “something in that string was NOT alphabetical!”

FAQ: Learn Python - Pyglatin - Check Yourself... Some More