Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from operator import contains
- from functools import partial
- from itertools import groupby
- from string import punctuation
- def censored(words, key, censor=lambda w: punctuation[:len(w)]):
- for is_cens, ws in groupby(words, key):
- yield from map(censor, ws) if is_cens else ws
- print( ' '.join( censored("pidar Illya poshel nahui".split(),
- partial(contains, 'nahui suka'.split())
- )
- ))
Advertisement
Add Comment
Please, Sign In to add comment