Censor lesson #10


I came up with the following code but I get the error "For hey, hey, hey, it should return *** *** *** but it returns ***." I thought multiplying it by the length of the text would work?

def censor(text, word):
   text = text.split()
   for a in str(text):
      for q in str(word):
         word = "*" * len(text)
   return text


you forgot to join the words


Yes you need to join the words. When I get there I will post the code here.


Is there any particular reason you are using .split()? I was able to complete the function with .replace().


The hint stated that using the .split() function would allow me to complete this after looping through the word.


While it may be a solution, it goes beyond what has been learned so far and is not really practice in the strictest sense. As a posted solution it will be edited.


Oops, sorry. I'll be more conscientious about that in the future.


How do I join words again?


Have you looked it up? separator.join(string/list)



A post was split to a new topic: 10. censor


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