There are multiple ways to loop back in python For example we have
arr=[5,6,8]
for i in range(len(arr)-1, -1, -1):
print(i," ",arr[i])
which gives
2 8
1 6
0 5
I can solve what I need with that, but I am curious. There is another way to loop back which is
for im in arr[::-1]:
print(im)
Looks nice, right? This gives
8
6
5
My question is, using this second method is there a way to get not only the element but also the index? (the 2,1,0)