[Tutor] List elements as indices to another list

Alan Gauld alan.gauld at btinternet.com
Mon Aug 4 01:33:56 CEST 2008


"Carlos Laviola" <carlos.laviola at gmail.com> wrote

>>>> i
> [0, 1, 2]
>>>> j
> [2, 1, 0]
>
> Theoretically, I could then just iterate over range(len(M)) and grab
> M[i[N]j[N]], but that's not legal. What would be the right way of 
> doing
> this?

M [ i[N] ]  [ j[N] ]

You just missed a couple of brackets...

HTH,

Alan G 




More information about the Tutor mailing list