title: Unusual function behavior - returns different results for same variable?
body: <p>I have a list as part of a game I'm working on. Let's say:</p>
  
  <pre><code>my_list = [1, 2, 3, 4, 5]
  </code></pre>
  
  <p>I also have a function:</p>
  
  <pre><code>def my_function(my_list):
      a = [x for x in my_list if x &lt; 4]
      b = [x for x in my_list if x &lt; 4] ## exactly the same as for `a`
      print(a)
      print(b)
  </code></pre>
  
  <p>The result of calling <code>my_function(my_list)</code> is:</p>
  
  <p><code>a</code> prints as it should:</p>
  
  <pre><code>[1, 2, 3]
  </code></pre>
  
  <p>But <code>b</code> prints an empty list:</p>
  
  <pre><code>[]
  </code></pre>
  
  <p>Obviously the code above is just an example (it would be highly impractical for me to copy my whole code), but it's pretty much a copy of the issue I'm facing in my code. Does anyone know what could be causing such behavior?</p>