Censor


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/4?curriculum_id=4f89dab3d788890003000096


Loops never work, and the .replace() method doesn't do anything at all.


Ive spent like half an hour at this one exercise, can someone please give me the solution :frowning:


Replace this line with your code.


#2

asking and giving solution is not according to the guidelines

please copy paste your code to the forum, so we can help you understand your problem, improve your understanding and work toward a solution


#3

def censor(text, word):
new_text = text.replace(word, "*" * len(word)
return new_text the indent disappears when i post this to the forum
The errors I got:

  1. File "python", line 3
    return new_text
    ^
    SyntaxError: invalid syntax

  2. Your code threw a "global name 'censor' is not defined" error.


#4

look at your parentheses on the line above return, the number of opening parentheses doesn't match the number of closing parentheses


#5

wow... That was surprisingly simple, Thank you so much!


#6

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