Skip to content

Instantly share code, notes, and snippets.

@diogojorgebasso
Created May 11, 2022 12:26
Show Gist options
  • Save diogojorgebasso/688d79c3e3680afd211331c8cb9893bd to your computer and use it in GitHub Desktop.
Save diogojorgebasso/688d79c3e3680afd211331c8cb9893bd to your computer and use it in GitHub Desktop.
How to invert a list in python?
lista_inicial = [1,2,3,4,5] #input of the list
def inversion_sequency(lista):
n = len(lista)-1
for j in range(0,n//2+1):
print(j)
lista[j], lista[n-j] = lista[n-j], lista[j]
return lista
print(inversion_sequency(lista_inicial))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment