Computer Science, asked by sumaiya1711, 3 months ago

Write a method/function DISPLAYWORDS() in python to read lines from a text file STORY.TXT and display those words, which are similar to ‘what’ or ‘What’. e.g. if the file contains following text. "What is the matter in board examination

Answers

Answered by valeriy69
1

\small\mathsf\color{pink}{Solution\: using\: python\: 3}

import re

def display_words(file):

with open(file) as f:

for line in f:

matches = re.findall("what", line, flags = re.I)

for x in matches:

print(x)

if __name__ == "__main__":

display_words("story.txt")

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

Similar questions