Count Uppercase Letters
EasyPractice library · +10 XPstringsloopscounting
Given a string S, count the number of uppercase English letters in it. The string S will only contain English letters (uppercase or lowercase).
Print the total count of uppercase letters.
Input
A single line containing the string S.
Output
A single integer representing the count of uppercase letters.
Constraints
The length of S is between 1 and 1000, inclusive.
Time limit 1 s (native code; slower languages get more)Memory 256 MB14 hidden tests
Example 1
Input
HelloWorld
Output
2
The string 'HelloWorld' contains two uppercase letters: 'H' and 'W'.
Example 2
Input
alllowercase
Output
0
The string 'alllowercase' contains no uppercase letters.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
HelloWorld
Example 2 input
alllowercase