Programming Examples

Python program to input any string and count number of uppercase and lowercase letters


Write a program to input any string and count number of uppercase and lowercase letters.

Solution

s=raw_input("Enter any String")
rint s
u=0
l=0
i=0
while i<len(s):
	if (s[i].islower()==True):
		l+=1
	if (s[i].isupper()==True):
		u+=1
		i+=1
print "Total upper case letters :", u
print "Total Lower case letters :", l
▶ RUN

Output/ Explanation:

Enter any String Python PROG
Python PROG
Total upper case letters: 5
Total Lower case letters: 5
Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad