indice d'un element dans une liste python 1

indice d’un element dans une liste python

week = ['monday','tuesday','wednesday']

week.index('tuesday')
>>> 1

"""Warning => error if the element isn't in the list"""

Here is what the above code is Doing:
1. The index() method is called on the list week.
2. The method is passed the argument ‘tuesday’.
3. The index() method returns the index of the argument passed to it.

Similar Posts