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
Output

Enter any String Python PROG
Python PROG
Total upper case letters: 5
Total Lower case letters: 5
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad