On 09/13/2012 04:16 PM, Bala subramanian wrote:
> Friends,
> I have a 2D matrix (a numpy array) and i am looping over each row in
> the matrix. I would like to know how i can find the index of each
> element in a while looping a row. Is there any function in numpy.
>
> Thanks
>

Perhaps you're asking a more general question.  When iterating over a
collection, sometimes you not only want the object, but you also want
the index you might have used to fetch it.

for row in rows:
   dosomething with row

for index, row in enumerate(rows):
   dosomething with row and with index

Now if rows be a list, or whatever numpy decides to call it, then you
can manipulate the particular one with rows[index].



-- 

DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to