views:

937

answers:

1

Is there any built-in methods that are part of lists that would give me the first and last index of some value, like:

verts.IndexOf(12.345)
verts.LastIndexOf(12.345)
+6  A: 

Sequences have a method index(value) which returns first of first occurrence.
You can run it on verts[::-1] to find out the last index.

SilentGhost
Thanks, how do you perform list[::-1]?verts[::-1]?
Joan Venge
yep, i've edited the answer
SilentGhost
Btw verts[::-1] just reverses the list, right? So I have to compensate for the index, right?
Joan Venge
sure, it'll be: len(verts) - 1 - verts[::-1].index(value)
SilentGhost