number of uppercase letters in a string python code example
Example 1: Count upper case characters in a string
def n_upper_chars(string):
return sum([int(c.isupper()) for c in string])
Example 2: python 3 calculate uppercase lowercase letter
world = input()
upper,lower = 0,0
for i in world:
upper+=i.isupper()
lower+=i.islower()
print("UPPER CASE {0}\nLOWER CASE {1}".format(upper,lower))