Computer Science, asked by ashreya1906, 5 months ago

Write a function vowcount() in python which counts and display the occurrence of words starting with a vowel in the given string.

Example: if the string content is as follows:

“This is the official website of this company”

Output:

Vowcount() function should display the output as:

is

official

of

Vowel words: 3

Answers

Answered by jai696
3

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

def vowcount(file):

vowel_counter = 0

vowel_words = []

vowels = ["a", "e", "i", "o", "u"]

upper_vowels = [c.upper() for c in vowels]

with open(file) as f:

for line in f:

for word in line.split():

if word[0] in vowels or word[0] in upper_vowels:

vowel_counter += 1

vowel_words.append(word)

print("\n".join(vowel_words))

print(f"Vowel Words: {len(vowel_words)}")

vowcount("file.txt")

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions