When dealing with strings, it’s also important to check if some conditions hold. Below are several popular methods that are used to check for some conditions in a string:
Method
Description
Examples
Results
isupper()
Check if all the letters are uppercase
'Anna'.isupper()
'ANNA'.isupper()'AnnA'.isupper()
FalseTrueFalse
islower()
Check if all the letters are lowercase
'Anna'.islower()
'anna'.islower()'AnnA'.islower()
FalseTrueFalse
istitle()
Check if all the words start with uppercase and are followed by lowercase letters
Bear in mind that memorizing these methods is not necessary. Despite the names being very intuitive, a short googling will lead you to the method you actually need. This small table is just a fraction of the useful methods to demonstrate what is possible with a single line of Python code.
Note that string does not have contains() method as there is already an in keyword present which checks if one string is contained in another.
Challenge
Given a string, count the number of uppercase, the number of lowercase, and the number of space letters.
The input contains a single line of text which needs to be analyzed.
The program should print a single line with 3 numbers - the number of uppercase letters, the number of lowercase letters, and the number of space letters.