Kodewick
Start learning →
Basic←→0 / 100

Chat filter

#038BasicStringsLoops3 min

The game chat should stay friendly. Write clean_chat(message) to replace each word in bad_words with *** (however long it was). Messages are all lower case; with no bad words, it comes back as it is.

Examples
clean_chat("you noob")→'you ***'
clean_chat("gg, nice game")→'gg, nice game'
main.py
def clean_chat(message):
    bad_words = ["noob", "loser"]
    for word in bad_words:
        # your code here: replace word in message with "***"
        pass
    return message
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.