w3ajay

tally tutorial point, ms word 2013, ms excel 2013, ms powerpoint 2010,ccc question with answer in hindi 2021, Tally Prime in hindi , tally prime,Python,in python,programming in python,python

Thursday, July 18, 2024

Read a text file and display the number of vowels/consonants/uppercase/lowercase characters in the file.

 



# Read a text file and display the number of vowels/consonants/uppercase/lowercase characters in the file. 

f=open("ram.txt")

u=s=v=c=0

data=f.read()

for i in data:

    if i.isalpha():

        if i.isupper():

            u+=1

        if i.islower():

            s+=1

        if i.lower() in 'aeiou':

                v+=1

        else:

            c+=1

print("Totalof uppercase is => ",u)

print("Totalof lowercase is => ",s)

print("Totalof vowels is => ",v)

print("Totalof consonants is => ",c)

f.close()


Output



No comments:

Post a Comment

for more information please share like comment and subscribe