CBSE · 083Class XII · 2025Section C3 marks
Question 29(or)
4 March 2025 · Computer Science (083)
Write a Python function that displays all the words starting and ending with a vowel from a text file "Report.txt".
Answer
python
def vowels():
F=open('Report.txt')
Data=F.read()
Words=Data.split()
for Word in Words:
if Word[0] in 'aeiouAEIOU':
if Word[-1] in 'aeiouAEIOU':
print(Word,end=' ')
F.close()Explanation
Reads entire file, splits into words, checks first and last character of each word against vowel string.