+ 1

How to find the index of a an element in the list (python)

29th Aug 2020, 12:34 PM
Tayyib
Tayyib - avatar
2 odpowiedzi
+ 5
list2.index('r') to find the index of r in list2
29th Aug 2020, 12:36 PM
Anthony Tannous
Anthony Tannous - avatar
+ 3
I am assuming you mean finding the index of an element by name? If yes, there is the index() method ["foo", "bar", "baz"].index("bar") returns: 1
29th Aug 2020, 12:37 PM
Steven M
Steven M - avatar