Amrith
Amrith

Reputation: 57

how to check character by character in a line if upper case or lower case and count the upper case and lower case?

I have tried using isupper and islower but no luck.Can you please suggest a method.I have tried using islower but it returns some number not true or false.

s=input()
size=len(s)
for i in range(0,size):
    print(s[i].isupper)

expected output?

Upvotes: 0

Views: 82

Answers (1)

pramesh
pramesh

Reputation: 1954

this will count total lowercase and uppercase character

s=input()
size=len(s)
upper = 0
lower = 0
for i in range(0,size):
    if(s[i].isupper()):
      upper += 1
    elif (s[i].islower()):
      lower += 1
    else:
      pass

print("total upper = {}".format(upper))
print("total lower = {}".format(lower))

Upvotes: 1

Related Questions