To count letter in python string, we will use two python function
isupper()
islower()
Let suppose the string is like that
string = "Hello Friend this is Codersarts"
Then the output string look like that:
uppercase : 3
lowercase : 24
Solution:
string = "Hello Friend this is Codersarts"
d={"UPPER CASE":0, "LOWER CASE":0}
for c in s:
if c.isupper():
d["UPPER CASE"]+=1
elif c.islower():
d["LOWER CASE"]+=1
else:
pass
print ("UPPER CASE", d["UPPER CASE"])
print ("LOWER CASE", d["LOWER CASE"])
Output:
uppercase : 3
lowercase : 24
For other top rated Codersarts python program links
For given latitude value check the location on equator in python
Calculate distance between two points on Earth the latitute and longitude given in degrees
Write a program of Rational Numbers Addition,Subtraction, Multiplication, Division in python
Design and implement a "Golf Club" program that records information about golfers and tournaments
Concatenate First, mid and last character of String in Python
A set of utilities to manipulate polynomials, Addition, subtraction, Multiplication and evaluation
For other top rated python program visit here
If you like Codersarts blog and looking for Assignment help,Project help, Programming tutors help and suggestion you can send mail at contact@codersarts.com.
Please write your suggestion in comment section below if you find anything incorrect in this blog post