title: Python,join() function, adding space between words
body: <p>I need to write a function that takes two strings (text and word) and returns the text with the chosen word replaced with asterisks (the number of asterisks should correspond to the number of letters in the censored word.).</p>
  
  <p>For example:</p>
  
  <p>if text="hey hey hey" and word="hey" the returned text should be:</p>
  
  <pre><code>'*** *** ***'
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>def censor(text,word):
      text = text.split(" ")
      asterisks=[]
      text_with_asterisks=[]
  
      for item in text:
          if item not in word:
              text_with_asterisks.append(item)
          else:
              asterisks=[]
              for letter in word:
                  asterisks.append("*")
  
              text_with_asterisks.append(' '.join(asterisks))
      return (" ".join(text_with_asterisks))
  </code></pre>
  
  <p>The code works but it returns:</p>
  
  <pre><code> ********* 
  </code></pre>
  
  <p>and not</p>
  
  <pre><code>*** *** ***. 
  </code></pre>
  
  <p>Once I use the line:</p>
  
  <pre><code>return ("_".join(text_with_asterisks))
  </code></pre>
  
  <p>instead I get:</p>
  
  <pre><code>'***_***_***'
  </code></pre>
  
  <p>I don't understand why the "  " is ignored and how can I add a space between the words.</p>
  
  <p>Thanks!</p>