title: Python - TypeError: 'int' object has no attribute '__getitem__'
body: <p>I'm a beginner in python and i'm having trouble with iterating in a list. This is the piece of code I'm having trouble with:</p>
  
  <pre><code>for x in list(xrange(instance.nbw)):
           sddpbw.append(choice(sddpfw))
  print sddpbw
  
  for t in reversed(list(xrange(instance.T))): 
  
      if t&gt;0:
          for u in sddpbw:
              # for n in list(xrange(1,instance.NUMPATHS+1,passo)):
              for n in pairs[t][u-1]:
                  if n != u:
                      for p in instance.HP:
                          x[n-1][t-1][p-1]=x[u-1][t-1][p-1]
  </code></pre>
  
  <p>I have a previous list (sddpfw) and want to chosse some elements from it and create another list (sddpbw).
  The exit is:</p>
  
  <pre><code>[4, 2]
  Traceback (most recent call last):
     File "PDDE.py", line 179, in &lt;module&gt;
         x[n-1][t-1][p-1]=x[u-1][t-1][p-1]
  TypeError: 'int' object has no attribute '__getitem__'
  </code></pre>
  
  <p>But if I comment the section that creates the variable sddpbw and create it mannually it works fine:</p>
  
  <pre><code># for x in list(xrange(instance.nbw)):
      # sddpbw.append(choice(sddpfw))
  sddpbw=[4, 2]
  print sddpbw
  </code></pre>
  
  <p>I can´t figure out why this is happening.</p>