Guest User

Untitled

a guest
Sep 8th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. from operator import contains
  2. from functools import partial
  3. from itertools import groupby
  4. from string import punctuation
  5.  
  6. def censored(words, key, censor=lambda w: punctuation[:len(w)]):
  7.     for is_cens, ws in groupby(words, key):
  8.         yield from map(censor, ws) if is_cens else ws
  9.  
  10. print( ' '.join( censored("pidar Illya poshel nahui".split(),
  11.                   partial(contains, 'nahui suka'.split())
  12.                   )
  13. ))
Advertisement
Add Comment
Please, Sign In to add comment