Count Uppercase Letters
Easy · rating 950 · Strings
Read a single line and print how many of its characters are uppercase English letters (A–Z).
Editorial
Approach
Scan the line and count characters that fall in the range A–Z. Most languages expose an isupper helper, but a direct range check works everywhere.
s = input()
print(sum(1 for c in s if c.isupper()))Complexity
Time: O(n). Space: O(1).
Related problems
- Character Count — Easy
- Count Words — Easy
- Distinct Words — Easy
- Product of Digits — Easy
- Reverse a String — Easy
- Reverse the Words — Easy