Cuda / Miracles | Cudowne lata / The Wonder Years | Cudzoziemianie / People of Earth

, asked
Views : 1

How to find the index of an item given a list containing it in Python?

How to find the index of an item given a list containing it in Python?                    

1 Answer
Malhar Lathkar

Position of an element in a list (any sequence data type for that matter) is obtained by index() method. This method finds first instance of occurrence of given element.

>>> L1=[45, 32, 100, 10, 24, 56]
>>> L1.index(24)
4

Advertisements
Related Questions