Write a function VowelCount() in Python, which should read each character of a text file MY TEXT FILE.TXT, should count and display the occurrence of alphabets vowels.
Example:
If the file content is as follows:
Updated information
As simplified by official websites. The VowelCount() function should display the output as:
A or a:4
E or e :4
1 or 1:8
O or 0:0
U or u: 1
Answers
Answered by
1
Answer:
def count_A_M(): f=open("story.txt","r") A,M=0,0 r=f.read() for x in r: if x[0]=="A" or x[0]=="a" : A=A+1 elif x[0]=="M" or x[0]=="m": M=M+1 f.close() print("A or a: ",A) print("M or m: ",M)Read more on Sarthaks.com - https://www.sarthaks.com/968966/write-function-amcount-in-python-which-should-read-each-character-of-a-text-file-story-txt
Similar questions