In the personal project for the Censor Dispenser (https://www.codecademy.com/practice/projects/censor-dispenser), the exercise asks if your censor function can handle punctuation elements. After doing the initial string split on spaces, I thought of iterating through each element in the resulting list, to look for exclamation points, then commas then periods. The problem is that if I iterate and use split again when it finds these things, it then creates a nested list, whereas I’d need those strings to simply remain in the parent list for my function to work.
I have tried the following (at first just for exclamation marks, to see if I get the concept right):
def heavy_censor(message): message2 = message.split(" ") message3 =  for word in message2: index = message2.index(word) if word.find("!") != -1 and len(message2[index]) > 1: message3 = message2[index].split("!") message2[index : index] = message3 message2 = message2.remove(word)
But it returns an AttributeError that NoneType object has no value and I have no idea what this means as I’ve never seen this error before.
Other attempts to iterate, splitting and adding to parent list have always just ended in infinite loops.
I’ve looked through python documentation and googled but I couldn’t find another method of splitting a string within a list without creating a nested list at the newly split index.