Search
 
SCRIPT & CODE EXAMPLE
 

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)))) 
Comment

PREVIOUS NEXT
Code Example
Python :: fastapi upload file save 
Python ::  
::  
Python :: iterate through directories in python 
Python ::  
Python ::  
::  
Python ::  
:: pytest local modules 
Python ::  
Python :: all the symbols on a keyboard python list 
::  
Python ::  
:: python logo png 
Python ::  
Python ::  
::  
Python ::  
::  
Python :: migrations.rename_field django 
::  
::  
Python ::  
::  
Python ::  
::  
::  
:: windows 10 python path 
::  
Python :: read an excel file 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =