30

I am a pretty new to python. I have created an empty matrix

a = numpy.zeros(shape=(n,n))

Now I can access each element using

a.item(i,j)

How do I set an index (i,j)?

0

3 Answers 3

65

Here's how:

a[i,j] = x
Sign up to request clarification or add additional context in comments.

Comments

11

Or

a.itemset((i,j),x)

Comments

3

Try this

a[i,j]=5

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.