Write a function in PYTHON to count the number of vowels present in a text file “BOOK.txt”
1
Expert's answer
2021-09-07T06:59:57-0400
def count_vowels(path='BOOK.txt'):
vowels = ('a', 'e', 'o', 'i', 'u')
count = 0
with open(path) as file:
for line in file:
for char in line:
if char in vowels:
count += 1
return count
Comments
Leave a comment