Python unsubscriptable

The problem in your sample code is that the array "a" contains two different types: it has 4 2-element lists and one integer. You are then trying to sub-script every element in "a", including the integer element.

In other words, your code is effectively doing:

print [1,2][0]
print [5,3][0]
print 5[0]
print [5,6][0]
print [2,2][0]

That middle line where it does "5[0]" is what is generating the error.


It means you tried treating an integer as an array. For example:

a = 1337
b = [1,3,3,7]
print b[0] # prints 1
print a[0] # raises your exception