Explore Library
Code QuizIntermediate

Summing Over the Wrong Axis

Find the axis mistake when computing per-row totals of a matrix.

Codepython
import numpy as np

X = np.array([[1, 2, 3],
              [4, 5, 6]])
# Goal: total of each ROW -> expect [6, 15]
row_totals = X.sum(axis=0)
print(row_totals)

What is the bug in this code?