Hi @peeyushchawla ,
Note the message that Codecademy displays ...
Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "*** *** *** " when it should return "*** *** ***".
Your function returns an extra space at the end of the string, and that is why Codecademy does not like it.
You are passing
result to the
join method here, when
result refers to a string ...
join should be passed an argument consisting of a
list of words and strings of asterisks, in this exercise. Start out the function with ...
result = 
Then, instead of this ...
result += '*' * len(worm) + " "
... and this ...
result += worm
append each new string to the
result list, with ...
result.append('*' * len(worm))
... and ...
join to combine the strings in the
result list together, with a space in between each ...
return " ".join(result)