Python Shrinking Repeated-Number Triangle (Pattern 16)

Python Code
for x in range(1, 6):
    for y in range(5, x - 1, -1):
        print(x, end="")
    print()

Output:

Output of the Python Shrinking Repeated-Number Triangle pattern
BEGINNER WALKTHROUGH

How the Shrinking Repeated-Number Triangle works

The rows contain five 1s, four 2s, three 3s, two 4s, and one 5.

01

Build the rows

The outer counter x increases from 1 to 5, selecting the digit printed on each row.

02

Choose what each row prints

The inner range counts down from 5 to x, so each new row has one fewer copy of x.

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.