<[EMAIL PROTECTED]> a écrit dans le message de news: 
[EMAIL PROTECTED]
> For example, assuming that I have a list like:
>
> mylist = [0, 1, 1, 1, 1, 5, 6, 7, 8, 1, 10]
>
> I would like to find the indices of the elements in the list that are 
> equal
> to 1 (in this case, the 1,2,3,4,9 elements are equal to 1).

List comprehension is your friend:

PythonWin 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on 
win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) - see 
'Help/About PythonWin' for further copyright information.
>>> mylist = [0, 1, 1, 1, 1, 5, 6, 7, 8, 1, 10]
>>> [i for i, j in enumerate(mylist) if j==1]
[1, 2, 3, 4, 9]
>>> 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to