Q. Write a program to read a text file and display the count of lowercase and uppercase letters in the file.
Answer :-
myfile = open("Answer.txt", "r") lcount = 0 ucount = 0 file_data=myfile.read() for i in file_data: if i.isupper() == True: ucount = ucount + 1 elif i.islower() == True: lcount = lcount + 1 else: None print("Uppercase letters in the file :", ucount) print("Lowercase letters in the file :", lcount) myfile.close()
Data in the file Answer.txt :-
There are two types of people living in the world,
one people who have visited (https://www.pathwalla.com/) website
and other people who have not visited (https://www.pathwalla.com/) Website.
Output :-
Uppercase letters in the file : 2
Lowercase letters in the file : 146
Output nhi hai kya iska
ReplyDeleteOk. 😊😊
Delete✨️
ReplyDelete: )
DeleteAmazing
ReplyDeleteThank you : )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )