Python Descending Repeated-Number Triangle (Pattern 20)

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

Output:

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

How the Descending Repeated-Number Triangle works

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

01

Build the rows

The outer counter x counts down from 5 to 1 and supplies the digit for each row.

02

Choose what each row prints

The inner loop runs x times and prints x, so both the repeated digit and row width decrease together.

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.