Answer to Question #231136 in Python for Shreya

Question #231136
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS