Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)))) 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #higlight #words #python
ADD COMMENT
Topic
Name
1+2 =