title: Python - how does the variable affect the loop
body: <p>I am wondering why there is a different result when I change from arr[n] in version 1 to n in version 2:</p>
  
  <p><strong>Version 1</strong></p>
  
  <pre><code>def summer_69(arr):
      list_sum2 = 0
      n = 0
      for arr[n] in range(arr[n] == 6, (arr[n]== 9) + 1):
              list_sum2 += arr[n]
      print(list_sum2)
  
  summer_69([1, 3, 5])
  summer_69([4, 5, 6, 7, 8, 9])
  </code></pre>
  
  <p><strong>Result for Version 1</strong></p>
  
  <pre><code>0
  0
  </code></pre>
  
  <p><strong>Version 2</strong></p>
  
  <pre><code>def summer_69(arr):
      list_sum2 = 0
      n = 0
      for n in range(arr[n] == 6, (arr[n]== 9) + 1):
              list_sum2 += arr[n]
      print(list_sum2)
  
  summer_69([1, 3, 5])
  summer_69([4, 5, 6, 7, 8, 9])
  </code></pre>
  
  <p><strong>Result for Version 2</strong></p>
  
  <pre><code>1
  4
  </code></pre>