English

Write a function, vowelCount() in Python that counts and displays the number of vowels in the text file named Poem.txt.

Advertisements
Advertisements

Question

Write a function, vowelCount() in Python that counts and displays the number of vowels in the text file named Poem.txt.

Short/Brief Note
Advertisements

Solution

def vowelCount ():
           fObj = open("Alpha.txt","r")
           data = str(fObj.read())
           cnt=0
           for ch in data:
                    if ch in "aeiouAEIOU":
                            cnt=cnt+1
           print (cnt)
           fObj .close()
shaalaa.com
Reading from a Text File in Python
  Is there an error in this question or solution?
2023-2024 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×