fork download
  1. def censor(text, word):
  2. return ' '.join(['*' * len(w) if w == word else w for w in text.split()])
  3.  
  4. print(censor('Yo go fro yo go', 'go'))
  5. print(censor('Bingo', 'go'))
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
Yo ** fro yo **
Bingo