Advertisements
Advertisements
Question
Write and call a Python function to read lines from a text file STORIES.TXT and display those lines which doesn’t start with a vowel (A, E, I, O, U) irrespective of their case.
Code Writing
Advertisements
Solution
def display_non_vowel_lines():
with open("STORIES.TXT", "r") as file:
print("Lines that don't start with a vowel:")
lines = file.readlines()
for line in lines:
if line[0].lower() not in 'aeiou':
print(line)
display_non_vowel_lines()shaalaa.com
Is there an error in this question or solution?
