Learn
PygLatin
Check Yourself... Some More

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:

Instructions

1.

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!

Folder Icon

Take this course for free

Already have an account?