Need help with Censor


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>
I expect all the cuss words to join together but they don’t print out. Am I using join correctly?

```python

Replace this line with your code.
def censor(text, word):
for cuss_word in text.split(’ '):
if cuss_word == word:
cuss_word = ‘*’ * len(word)

return ''.join(cuss_word)

print(censor(‘hey hey hey no’, ‘hey’))

<do not remove the three backticks above>

#2

cuss_word = ‘*’ * len(word) assigns the * for that word. But now how can you replace it within the original text? Think about how to replace a value in an array.

Also, make sure your code is indented properly, as Python requires proper indentation to run the code blocks.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.