Reputation: 4275
Im trying this but doesn't seem to work:
A = {{1,2},{3,4}}
A[[1]][[2]] = 5;
How could I do that?
Currently I'm doing
list = {3,5};
A[[2]] = list;
Upvotes: 2
Views: 242
Reputation: 61016
Your code is right, except for a minuscule error :)
You wrote:
A = {{1, 2}, {3, 4}} A[[1]][[2]] = 5;
^
^
|
This space means
multiplication!
The correct code is
A = {{1, 2}, {3, 4}} ; A[[1]][[2]] = 5;
Usually written as:
a = {{1, 2}, {3, 4}} ;
a[[1, 2]] = 5;
Remember to start your identifiers with lowercase letters, as capitals are reserved for system's names
Upvotes: 1