Free lab Real Python 3. Zero installs. Your code stays in this browser. Open the playground

Matrix Diagonals

Hard · 75 XP

For the 3×3 matrix in the starter, print the sum of the main diagonal, then the sum of the anti-diagonal.

Target output
22
18
Blank · autosaved
PYmatrix-diagonal.py
Run your code to check it…
Your next ten minutes

Write Python that does something useful.

Start free. No install, no card, no passive video marathon.

Start learning free → Explore the path