In a list of integer values
a = [4, 8, 2, 3, 8, 5, 8, 8, 1, 4, 8, 2, 1, 3]
I have to find the index of the last item with value 8
. Is there more elegant way to do that rather than mine:
a = [4, 8, 2, 3, 8, 5, 8, 8, 1, 4, 8, 2, 1, 3]
for i in range(len(a)-1, -1, -1):
if a[i] == 8:
print(i)
break