Python Hourglass Number-Sequence Pattern (Pattern 78)

Python Code
size = 4
for x in range(size, -(size + 1), -1):
    for y in range(1, abs(x) + 1):
        print(" ", end="")
    p = 1
    for z in range(size, abs(x) - 1, -1):
        print(str(p) + " ", end="")
        p += 1
    print()

Output:

Output of the Python Hourglass Number-Sequence Pattern pattern
BEGINNER WALKTHROUGH

How the Hourglass Number-Sequence Pattern works

Every indented row restarts its numbers at 1, growing toward the center and then shrinking.

01

Build the rows

The outer loop covers both halves of the hourglass, and abs(x) determines each row width and its leading spaces.

02

Choose what each row prints

The p counter is reset to 1 inside every row, then increases once for each value printed.

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.