How to find the position of an item of a list in python?
11,750
Use l.index(n)
to find index of n
in list l
.
>>> x = [1,3,7]
>>> x.index(3)
1
Author by
Admin
Updated on June 05, 2022Comments
-
Admin almost 2 years
I have two lists. The first list has a specific length and the second list has unstable length. I want to assign the items from two lists. I use
colour_index = sel_pos%(len(colours))
. The sel_pos is the item's position from the unstable list. How to find the position every time?