Write a program to check number of uppercase, lowercase and digits
in a given string.
Answers
Answered by
0
Answer:
x=str(input("enter a string:"))
upper=0
lower=0
digit=0
for i in range(0,len(x)):
if x[i].isupper():
upper+=1
elif x[i].islower():
lower+=1
elif x[i].isdigit():
digit+=1
else:
pass
print(upper,lower,digit)
Answered by
1
def count_case(s):
obj = {"upper": 0, "lower": 0, "digits": 0}
for c in s:
if c.isdigit():
obj["digits"] += 1
if c.isupper():
obj["upper"] += 1
if c.islower():
obj["lower"] += 1
return obj
s = input("enter string: ")
for k, v in count_case(s).items():
print(f"{k}: {v}")
Similar questions