Why do you need M[i,:] and not only M[i] in numpy03

unfortunately the solution throws an error.

Hello Heike,

Do you have more information to provide ? Which notebook are you working on ? What is the goal of your code ? What is the error you are talking about, because your code seems to run perfectly ?

Hi thanks for following up - it was numpy 03 in python 101 (I thought putting the place in the question would be fine?

). I was wondering what the significance of ,: were as that seemed to indicate a slice of some sort. Why is that in the solution code?

Hello Heike,

You are right, the « : » are used for slicing. In the solution, it means that you want to access all the elements of the line. To give you another example, if you want to access the i+1th column you can write M[ : , i]. Here, your code is fine since M[i] is also returning the i+1 th line of your numpy array.

I hope this answers your question !

1 Like