On 13 May, 15:47, Stefan Behnel <stefan...@behnel.de> wrote:
> a, 13.05.2010 16:36:
>
> > this must be easy but its taken me a couple of hours already
>
> > i have
>
> > a=[2,3,3,4,5,6]
>
> > i want to know the indices where a==3 (ie 1 and 2)
>
>    indices = [ i for i,item in enumerate(a) if item == 3 ]
>
> > then i want to reference these in a
>
>    print [ a[i] for i in indices ]
>
> Stefan

thanks Stefan.  very useful.  I didn't get this from the python
documentation!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to