Suppose that I have the following sentence:
bean likes to sell his beans
and I want to replace all occurrences of specific words with other
I know its been a long time but Does this look much more elegant? :
reduce(lambda x,y : re.sub('\\b('+y[0]+')\\b',y[1],x) ,[("bean","robert"),("beans","cars")],"bean likes to sell his beans")