In: Computer Science
Please help!
Given below is the code for the question. PLEASE MAKE SURE
INDENTATION IS EXACTLY AS SHOWN IN IMAGE.
Please do rate the answer if it helped. Thank you.
inFilename = input('Enter input filename: ')
idx = inFilename.rindex('.')
outFilename = inFilename[:idx] + '.vowel_profile'
try:
f = open(inFilename, 'r')
except:
print('ERROR: could not open input file ',
filename)
countA = 0
countE = 0
countI = 0
countO = 0
countU = 0
for line in f:
line = line.lower()
countA += line.count('a')
countE += line.count('e')
countI += line.count('i')
countO += line.count('o')
countU += line.count('u')
fout = open(outFilename, 'w')
fout.write('A Frequence:{}\n'.format(countA))
fout.write('E Frequence:{}\n'.format(countE))
fout.write('I Frequence:{}\n'.format(countI))
fout.write('O Frequence:{}\n'.format(countO))
fout.write('U Frequence:{}\n'.format(countU))
fout.close()
print('Please check output file ', outFilename)