Test for Alphabetical Letters in Character String Using Python (Example Code)

In this Python programming tutorial you’ll learn how to test for letters from the alphabet in a string.

Introducing Example Data

x = "abcd1234"                        # Create character string with letters

Example: Check If String Contains Alphabetical Letters Using isalpha() Function

print(any(c.isalpha() for c in x))    # Test whether letters are contained in string
# True

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top