I new to Python, and computer programming in general, and have been trying to tackle this Censor Dispenser project. I’ve been stuck on step 5, where the objective is to create a function that will censor a specific word in 2 different lists, and the word before and after.
Here is what I have so far for this function, the error I’m getting is index is out of range.
I apoligize to the international community here for my code being newb-ish and out of wack.
Thanks for your help!
def censor_four(email, list_one, list_two):
email = email.split(" ") for word in list_one: for word in list_two: for key_word in email: for i in (range(len(email))): if key_word[i] == word: key_word[i] = "*" key_word[i + 1] = "**" key_word[i - 1] = "***" email = " ".join(email) return email