#247 · Strings · Beginner · 40 XP · about 8 min
A comments section hides rude words by replacing each of their letters with an asterisk. Write censor(text, banned) that returns text with every banned word censored.
banned, ignoring case. Only whole words count: if "ass" is banned, "class" stays as it is.* characters. Everything else in the text, spaces and punctuation included, stays exactly as it was.banned is a list of lowercase words.
censor('What the heck, HECK!', ['heck']) # returns 'What the ****, ****!' censor('The class has a bass player', ['ass']) # returns 'The class has a bass player' censor("Darn. Drat! It's DRAT again", ['darn', 'drat']) # returns "****. ****! It's **** again"
Texts contain only English letters, spaces and punctuation marks (no digits or underscores).
First solves only, ranked by stars and then time.