Skip to content

Instantly share code, notes, and snippets.

@tinshade
Created January 7, 2021 07:25
Show Gist options
  • Select an option

  • Save tinshade/fb96e971a8df9773bb44bc3206147a19 to your computer and use it in GitHub Desktop.

Select an option

Save tinshade/fb96e971a8df9773bb44bc3206147a19 to your computer and use it in GitHub Desktop.
A small python script that shows how you can iterate through an array in reverse, using FOR loop, without having manipulating the array itself.
#Reverse Iterate an array using FOR and range in python3.
arr = [2,4,-5,0,-120,23,2]
# range(start, stop, step)
for i in range(len(a)-1,-1,-1):
print(arr[i], end=" ") #Prints 2 23 -120 0 -5 4 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment