what is wrong with my python code?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Feb 7 15:31:13 EST 2007


Dongsheng Ruan a écrit :
> I got feed back saying" list object is not callable". But I can't figure out 
> what is wrong with my code.
 >
> A=[3,5,4,9,6,7]
> l=len(A)-1
> 
> for i in range(l):
>      print A(i) 
> 
The error message is quite clear when you remember that () is the call 
operator. For the subscribe operator, you want [].

And FWIW, Python for loops are smarter than that:


A = [3,5,4,9,6,7]
for i in A:
   print i





More information about the Python-list mailing list