Can somebody explain me what is the role of two indices of array instead of single index of array?

Viewed 55

Why am I getting an error when using h[0,0]. Also, what is the the purpose of h[[0,0]]?

enter image description here

1 Answers

In h[[0, 0]] gives you 0th postion and 0th position so,

print(h[[0, 0]])
# [0, 0]
h[[0, 0]] = [4, 6]
# Equivalent would be 
h[0] = 4
h[6] = 6

While for h[0, 0] is would raise IndexError since h is 1-D array here. If it were a 2-D array then it would give you output from 0th row and 0th column value.

Related