Python Repeated-Number Pyramid (Pattern 35)

Python Code
inc = 1
num = 1
for x in range(5, 0, -1):
    for y in range(x, 0, -1):
        print(" ", end="")
    print(str(num) * inc)
    num += 1
    inc += 2;

Output:

Output of the Python Repeated-Number Pyramid pattern
BEGINNER WALKTHROUGH

How the Repeated-Number Pyramid works

Centered rows repeat 1 once, 2 three times, 3 five times, and continue with odd-width rows.

01

Build the rows

The outer loop adds one row at a time, while a leading-space loop shifts each wider row toward the center.

02

Choose what each row prints

The inc counter grows by two, and num advances by one after each row; the current number is repeated inc times.

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.