- Library
- Challenges
- Python
A chat filter
Hide banned words in a game chat message with stars, whatever their capital letters, and leave every other word alone.
Write clean(message, banned). message is a chat line with words separated by single spaces. banned is a list of lower case words. Return the message with every banned word replaced by stars, one star per letter. Match whole words only, and ignore capitals: "NOOB" is banned if "noob" is. Every other word stays exactly as it was.
Python
clean("you are a noob lol", ["noob"]) # "you are a **** lol"Checks
- Banned words become stars
- Capitals and whole words
exercise_1.py to run
def clean(message, banned):
pass