How is that i get the reverse iteration using the following code. Should I be using the reduce function or something?
Example:
for i in range(4):
print i ////0 1 2 3
how do i print the same in the reverse order
3 2 1 0
a=[5,2,1,4,3]
I also want to print the above array in reverse using the index and not a[::-1]
i.e,i want to first print
a[4] //get index starting from last how to achieve this
a[3]
a[2]
a[1]
a[0]
Use the reversed function:
prints:
and
prints