Write a program VowelCounts.py that reads in ga.txt and counts the number of each kind of vowel, printing the results for each vowel to the terminal. Annotate the output so that it is understandable.
# Open file in Read Mode
f=open("ga.txt","r")
# Read Entire File and Assign it in to the Variable
fread=f.read()
#Count Vowels
print("Count of A : ",fread.count('a')+fread.count('A'))
print("Count of E : ",fread.count('e')+fread.count('E'))
print("Count of I : ",fread.count('i')+fread.count('I'))
print("Count of O : ",fread.count('o')+fread.count('O'))
print("Count of U : ",fread.count('u')+fread.count('U'))
# Close File
f.close()
Comments
Post a Comment