游戏聊天室要文明一点。写 clean_chat(message),把 bad_words 里的每个词都换成 ***(不管原来几个字母)。消息都是小写的;没有坏词就原样返回。
clean_chat("you noob")→'you ***'clean_chat("gg, nice game")→'gg, nice game'def clean_chat(message):
bad_words = ["noob", "loser"]
for word in bad_words:
# 在这里写:把 message 里的 word 换成 "***"
pass
return message
写好了先点「运行」试试示例,没问题再点「提交」。