Python Descending Repeated-Letter Triangle (Pattern 22)

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

Output:

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

How the Descending Repeated-Letter Triangle works

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

01

Build the rows

The outer loop counts down through character codes for E to A and also controls the row length.

02

Choose what each row prints

chr(x + 64) converts the current row code to a letter, which the inner loop repeats.

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.