title: Codecademy Practice Makes Perfect 10/15 (Word Censoring)
body: <p>I'm on Codecademy, the section called "Practice Makes Perfect", on problem 10/15, the word-censoring one. The problem goes like this:</p>
  
  <p>Write a function called <code>censor</code> that takes two strings, <code>text</code> and <code>word</code>, as input. It should return the text with the <code>word</code> you chose replaced with asterisks. </p>
  
  <p>My idea was to do this:</p>
  
  <pre><code>def censor(text, word):
      length_of_word = len(word)
      word_now_censored = '*' * length_of_word
      wordlist = text.split()
      for item in wordlist:
          if item == word:
              item = word_now_censored
      return " ".join(wordlist)
  </code></pre>
  
  <p>But, so it seems, changing the value of <code>item</code> in the for loop doesn't change the value of the item in the list.</p>
  
  <p>I thought another way could be to use a <code>while</code> loop, going from <code>i = 0</code> to <code>i &lt; len(wordlist)</code>, and then modify <code>wordlist[i]</code> as needed, but I'd just like to understand why my <code>for</code>-loop method doesn't work.</p>