title: Assign Function to Initialized Variable in For Loop?
body: <p>A question regarding the variable initialized in a for-loop:</p>
  
  <p>The setup:</p>
  
  <pre><code>from urllib import urlopen
  
  WORD_URL = "http://learncodethehardway.org/words.txt"
  
  WORDS = []
  </code></pre>
  
  <p>My question is, when loading up the words from the url into the empty list WORDS, why does this work:</p>
  
  <pre><code>for word in urlopen(WORD_URL):
      WORDS.append(word.strip())
  </code></pre>
  
  <p>While this doesn't?</p>
  
  <pre><code>for word.strip() in urlopen(WORD_URL):
      WORDS.append(word)
  </code></pre>
  
  <p>Per my understanding, a function can be called on the initialized variable in a for loop, as long as the type of said variable supports that function.</p>
  
  <p>In this case, the type of the initialized variable is a string with a newline at the end, so I would think that <code>word.strip()</code> would work. Instead, I get the following error:</p>
  
  <pre><code>File "&lt;stdin&gt;", line 1
  SyntaxError: can't assign to function call
  </code></pre>
  
  <p>Why is this? </p>