2

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; 
0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

The question didn't actually have a space — it had a line break. SO put it on the same line because it was not wrapped in a code block. So what he originally had should've worked. I'm guessing this is what happened: Since the first line was not terminated, it printed the original contents of A to the notebook. OP took that to mean A has not been updated. If they had evaluated A again, they would've noticed the change. Either way, TL :)
a[[1]][[2]] = 5; doesn't work for me (Set::setps: A〚1〛 in assignment of part is not a symbol.), but a[[1,2]] = 5; works fine, thanks for the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.