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
1
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")
Similar questions