Python generator question


#1

def censor(text, word):
	return " ".join([w if != word else "*" * len(w) for w in text.split(" ")])

can aynone tell what is wrong with this? I am getting a syntax error.


#2

if != word

#3

can you be a bit more explicit? I see that I have that in my code. I don;t know what is wrong with it.


#4

To compare two values you will need to specify the two values to be compared

!= is an operator, it isn't part of a generator expression, there's no special syntax going on there.

That operator takes two arguments.


#5

now I see, thank you.