Python Shrinking Repeated-Letter Triangle (Pattern 18)

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

Output:

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

How the Shrinking Repeated-Letter Triangle works

The rows repeat A five times, B four times, C three times, D twice, and E once.

01

Build the rows

The outer counter x advances through A to E while the inner range loses one iteration on each row.

02

Choose what each row prints

chr(x + 65) selects one letter and the inner loop prints that letter for the row length.

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.