Immutable, Immutable! Don’t need no stinkin’....
adrius42 last edited by
I have tried searching the manual for a simple action...
I want to store variables in an array, I found and implemented many ways of doing this
Creating the array
Creating the first elements is easy with variablesarray.append(list)
I can even read them back with variablesarray[x][y]
But I cannot for the life of me figure out how to change an element in the array
In my old basic world it was very simple variablesarray[x][y]=newvalue
How can I achieve this simple variable change in Python, what am I missing.
I am confident it will be something simple... but I have yet to discover it.
Pointers gratefully received...
JonB last edited by
a=[[1,2,3],[4,5,6],[7,8,9]] print(a) print('aappend') a.append(4) print(a) print('a.extend ') a.extend([5,6]) print(a) print('a=99') a=99 print(a) print('del(a)') del(a) print(a) print('a.insert(1,2)') a.insert(1,2) print(a)
Are you getting an error of some sort? Maybe post the code that was failing. lists in python are generally mutable.
mikael last edited by
@adrius42, just making sure you are not appending or overriding
list, which is a built-in.