Program to find the total number of Uppercase letters

In this program, we will find the total number of Uppercase letters in a file.

Steps to solve the program
  1. Create a variable to count the total number of uppercase letters and assign its value equal to 0.
  2. Open the desired file using open() in reading mode.
  3. Use for loop iterate over the data.
  4. If the character is an Uppercase letter then add 1 to the variable that we have created.
  5. Use isupper() for this purpose.
  6. Print the output.
				
					f1=open("file1.txt","r")
data=f1.read()

is_upper = 0

for char in data:
    if char.isupper():
        is_upper += 1
        
print("NUmber of digits: ",is_upper)
				
			

Output :

				
					2
				
			

find the total number of digits in a file

find the total number of special characters in a file

Leave a Comment