Welcome to word finder in paragraph using python.
Welcome to word finder
This code is word finder in paragraph which line which word.
You can write/paste paragraph
paragraph = """ write a paragraph """
words_to_check = input("I am a word searcher, give me words (separated by commas): ").split(',')
words_to_check = [word.strip() for word in words_to_check]
lines = paragraph.split('\n')
for i, line in enumerate(lines):
if any(word in line for word in words_to_check):
highlighted_line = line
for word in words_to_check:
highlighted_line = highlighted_line.replace(word, f"** {word} **")
print(f"Line {i + 1}: {highlighted_line}")
Comments