Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python unsubscriptable

What does unsubscriptable mean in the context of a TypeError as in:

TypeError: 'int' object is unsubscriptable 

EDIT: Short code example that results in this phenomena.

a=[[1,2],[5,3],5,[5,6],[2,2]] for b in a:     print b[0]  > 1 > 5 > TypeError: 'int' object is unsubscriptable 
like image 812
Theodor Avatar asked Nov 08 '10 12:11

Theodor


1 Answers

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 
like image 106
kichik Avatar answered Sep 20 '22 17:09

kichik