Logo

Programming-Idioms

History of Idiom 222 > diff from v9 to v10

Edit summary for version 10 :
New Python implementation by user [fabrixxm]

Version 9

2020-04-15, 15:52:22

Version 10

2020-04-28, 19:08:29

Idiom #222 Find first index of an element in list

Set i to the first index in list items at which the element x can be found, or -1 if items does not contain x.

Idiom #222 Find first index of an element in list

Set i to the first index in list items at which the element x can be found, or -1 if items does not contain x.

Extra Keywords
position
Extra Keywords
position
Code
i = items.index(x) if x in items else -1
Doc URL
https://docs.python.org/3/library/array.html#array.array.index