Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 31, 2020 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/6a10f6a31abfd2ce7b596de20093e86c to your computer and use it in GitHub Desktop.
Save parzibyte/6a10f6a31abfd2ce7b596de20093e86c to your computer and use it in GitHub Desktop.
from copy import deepcopy
lista = [
[1, 2],
[3, 4],
]
otra_lista = deepcopy(lista)
print("lista:")
print(lista)
print("otra_lista:")
print(otra_lista)
# Modificar a lista
print("Modificando...")
otra_lista[0][0] = 4
# Y al imprimir, no debería haber modificado a "lista"
print("lista:")
print(lista)
print("otra_lista:")
print(otra_lista)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment