Dec-01-2020, 06:02 PM
(This post was last modified: Dec-01-2020, 06:02 PM by deanhystad.)
Need to indent all code inside a function.
Use i.lower() when testing instead of forcing the entire text to be lower case. You also want to retain the first letter of the censored word.
Use i.lower() when testing instead of forcing the entire text to be lower case. You also want to retain the first letter of the censored word.
def censor(text,word): t = text.split() n = [] for i in t: if(i.lower()==word): # Retain first letter if I and append "*" else: n.append(i) return " ".join(n)Do you also want to return a count? Functions can return more than 1 value.