Python Centered Number-Mirror Pyramid (Pattern 43)

Python Code
inc = 1
for x in range(1, 6):
    for y in range(5, x, -1):
        print(" ", end="")
    for z in range(1, inc + 1):
        print(abs(z - x), end="")
    inc += 2;
    print()

Output:

Output of the Python Centered Number-Mirror Pyramid pattern
BEGINNER WALKTHROUGH

How the Centered Number-Mirror Pyramid works

The rows mirror their digits around zero, growing from 0 to 1-0-1 and wider sequences.

01

Build the rows

The outer loop increases x while a separate loop removes leading spaces; inc grows by two each row.

02

Choose what each row prints

For every z position, abs(z - x) calculates its distance from the center, so the values mirror on both sides.

03

Keep the output aligned

The inner print calls use end="" to keep values on the same line. The final empty print() moves to the next row.