WeCodeAcademy

Indexing and Slicing

Index with square brackets, starting at 0. Negative numbers count from the end. A slice a[start:stop] stops before stop. For 2D arrays use a[row, column], and : means "all".

Examplepython
Open in editor »
Quick check

In `m = np.arange(1, 10).reshape(3, 3)`, what is `m[2, 0]`?

Your turn: write the code

Print the second column of m (all rows, column index 1).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.