Home » Python program to read a text file and display the count of lowercase and uppercase letters in the file

Python program to read a text file and display the count of lowercase and uppercase letters in the file

Below is the Python program to read a text file and display the count of lowercase and uppercase letters in the file

Program:

myfile=open("Answer.txt",'r')
ch=" "
lcount=0
ucount=0
while ch:
    ch=myfile.read(1)
    if ch.isupper()==True:
        ucount+=1
    else:
        lcount+=1
print("Uppercase lettres in the file:",ucount)
print("Lowercase letters in the file:",lcount)
myfile.close()