title: Python: Altering list values from a loop
body: <p>I am creating a simple Bin packing program in Python for a class and am having a scope issue that I cannot quite track down. I am attempting to alter the value in the ffBins list however the list the value is unaltered. </p>
  
  <p>The print results show what I expect ("10 5 5") as i is subtracted from j but it is not altering the value in the actual list as I am expecting. I suspect I need to point at the list in a different way during the loop but the solution is eluding me. Is there a simple way to alter the values in the list instead of just the current j variable?</p>
  
  <pre><code>    ffBins.append(10)
      for i in ffItems:
          itemPacked = 0
          for j in ffBins:
              #print(j)
              if j &gt;= i:
                  print(j),
                  print(i),
                  j = j-i
                  print(j)
                  itemPacked = 1
              #break
          if itemPacked == 0:
              ffBins.append(10)
              ffBins[-1] = ffBins[-1]-ffItems[i]
  </code></pre>