So my code is as below, I am aware it's not the correct code. I am just curious when I use "for each" loop I can't actually modify the list? Because I am studying Java in my university now and it told me in java "for each" loop, the n is a changing variable, it doesn't really refer to the actual element in the list? Is that the same in python?
def censor(text, word): new_sentence = "" parts = text.split() for n in parts: if n == word: n = "*" * len(word) print parts new_sentence = " ".join(parts) return new_sentence censor("hey hey hey", "hey")