Answers for "higlight words in python"

0

higlight words in python

from functools import reduce
from itertools import chain

text = 'left foot right foot left foot right. Feet in the day, feet at night.'
l1 = ['foot','feet']

print(reduce(lambda t, x: t.replace(*x), chain([text.lower()], ((t, colored(t,'white','on_red')) for t in l1))))
Posted by: Guest on October-21-2020

Python Answers by Framework

Browse Popular Code Answers by Language