If in lists two element is repeated , index of its first place is shown, why?? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

If in lists two element is repeated , index of its first place is shown, why??

l=['a','b','c','a','s'] print(l.index('a'))=0 why it's only 0 (3 should also be their)

22nd Oct 2018, 1:03 PM
Divam kachoria
Divam kachoria - avatar
1 Resposta
+ 7
It's just how the index method works. It returns the index of the first occurrence of the element.
22nd Oct 2018, 1:10 PM
Nikhil
Nikhil - avatar