samedi 30 mai 2020

Simple censor function does not work in python

I have created a function that takes a text and a word to censor in the text. It should return the text but with the censor word replaced with ****. But it does not censor the word.

def censor(text,word):
  if word in text:
    word="*"*len(word)
  return text

What's wrong with the code?

Aucun commentaire:

Enregistrer un commentaire