I am trying to figure out how I can count the uppercase letters in a string.
I have only been able to count lowercase letters:
def n_lower_chars(st
You can do this with sum, a generator expression, and str.isupper:
message = input("Type word: ")
print("Capital Letters: ", sum(1 for c in message if c.isupper()))
See a demonstration below:
>>> message = input("Type word: ")
Type word: aBcDeFg
>>> print("Capital Letters: ", sum(1 for c in message if c.isupper()))
Capital Letters: 3
>>>