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 Odpowiedź
+ 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