Now we know we have a non-empty string. Let’s be even more thorough and check that our string only contains letters.

Consider the following code:

x = "J123" x.isalpha() # This will return 'False'

In the first line, we create a string with letters and numbers.

The second line then runs the method .isalpha() which returns False since the string contains non-letter characters.

You can use .isalpha() to check that a string doesn’t contain any non-letter characters! For example:



Use and to add a second condition to your if statement. In addition to your existing check that the string contains characters, you should also use .isalpha() to make sure that it only contains letters.

Don’t forget to keep the colon at the end of the if statement!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?