0
Hello, I’m having a problem with Python3: When I create a list and assign the value of another variable to that list, when I change the variable the list is changed, code:
lista = ["uau", "nossa"]
lista1 = lista
lista1[0] = "impressionante"
print(lista1, lista)
# retorna ['impressionante', 'nossa'] ['impressionante', 'nossa']
I would like the variable "list" to stop changing and only "list1" to change, I would also like if you could tell me why this happens, thank you.
Linked: How to clone a list with Python 3? | What "immutable" really means? | Why lists (arrays) behave differently than common variables in Python? | Lists within lists: Even when sliced, there is connection between lists
– Woss