Censor lesson #10


#1

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


#2

you forgot to join the words


#3

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


#4

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


#5

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


#6

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.


#7

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


#8

How do I join words again?


#9

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

https://www.startpage.com/do/dsearch?query=separator.join(string|list)


#10

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


#11

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