Multiplication Grid
Completed
Read n and print an n×n multiplication grid. Each number is right-aligned in a 4-character column.
Input
One integer (1–12).
Output
n rows.
Example
Input
3
Output
1 2 3 2 4 6 3 6 9
Editor
Python
Hints
Use a loop inside a loop: rows outside, columns inside.
{x:4} pads a number to width 4.
Solution explanation
The inner loop runs completely for every iteration of the outer loop.
Show solution
n = int(input())
for r in range(1, n + 1):
row = ""
for c in range(1, n + 1):
row += f"{r * c:4}"
print(row)