This is a very simple question but I can't seem to understand why I am not getting it.
def listindex():
li = ['a', 'e', 'a', 'd', 'b', 'a', 'e']
for x in li:
if x == 'a':
print(li.index(x))
Result:
0
0
0
Expected Result:
0
2
5
Although it iterates over all the item I only get first item index, why is it? Also advise even though its pretty simple.