dfernan
asked on
which lists python
Hi,
Very short question. How do you search (without using for loops) in which position of an array certain condition holds.
I.e., list = [3,4,5,2,4,3,5,6,3,2,1,0]
which(list < 2) = [10, 11] cause in positions 10 and 11 the elements of the list are less than 2.
Very short question. How do you search (without using for loops) in which position of an array certain condition holds.
I.e., list = [3,4,5,2,4,3,5,6,3,2,1,0]
which(list < 2) = [10, 11] cause in positions 10 and 11 the elements of the list are less than 2.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No. I want to check for a condition. L.which(>=5) ... index in the list where the values are bigger or equal to 5. In your case, [2,6,7] cause in those positions L is bigger or equal to 5.
ASKER
sorry now i read ur second answer! yes, that's what i want. thanks!
Great. Glad to be of some help.
Thanks for the grade & points.
Good luck & have a great day.
Thanks for the grade & points.
Good luck & have a great day.
L = [3,4,5,2,4,3,5,6,3,2,1,0]
L.index( 5 )
Tells the location of the list variable that contains the specified value.
Is this what you want?