Python Repeating Alphabet Triangle Pattern (Reverse)

Beginner
7 min read
Updated: Sep 2026
3 programs
Live preview

What Is This Pattern?

A reverse repeating alphabet triangle grows by one repeated letter on each new line while letters count downward from the top of the alphabet range.

Remember
Rule: for letter i from top down to 'A',
      print i with growing width 1, 2, 3, …

E
DD
CCC
BBBB
AAAAA     ← 5 rows (top = 'E')

It is the reverse of Program 9: same growing widths, but letters step E → A instead of A → E. Print the outer letter inside the inner loop so each row stays uniform. Flip the widths in Program 11 to get the inverted twin.

How to Solve It

Two ways to emit the same shape — start with nested ord/chr loops, then optionally shorten with string multiplication.

MethodIdeaBest for
Nested loopsOuter = letter; inner = growing width; print outer letterLearning, interviews, exams
ch * repeatBuild a whole repeated-letter row in one callShorter demos once loops click

Pseudocode

Pseudocode
for i from top down to 'A':
    for j from top down to i:
        print i (no newline)
    print newline

Cheat sheet

GoalPattern
Countdown lettersfor i in range(ord('E'), ord('A') - 1, -1):
Grow widthfor j in range(ord('E'), i - 1, -1):
Uniform rowprint(chr(i), end="") — print i, not j
End the rowprint()
Top from rowstop = ord('A') + rows - 1
One-line shortcutprint(ch * repeat)
Forward twinProgram 9 (A, BB, CCC, …)

Printing Letters vs Starting a New Line

APIEffectUse for
print(ch, end="")Stays on the same lineEach letter on the row
print()Ends the current lineAfter the inner loop

Print letters without a newline, then end the row once.

Live Preview

Change the height and the reverse repeating triangle updates instantly — including the letter total.

Whole numbers from 1 to 26 (A–Z). Tap a chip or type a value — the preview redraws as you go.

Live result 5 rows · 15 letters
E
DD
CCC
BBBB
AAAAA

Worked Walkthrough — 'E' down to 'A'

Trace each outer-loop value of i and count how many times the inner loop runs.

iInner j rangePrinted rowRepeats
'E''E'..'E'E1
'D''E'..'D'DD2
'C''E'..'C'CCC3
'B''E'..'B'BBBB4
'A''E'..'A'AAAAA5

Total letter prints: 1 + 2 + 3 + 4 + 5 = 15 = 5×6/2. That triangular sum is why time is O(n²).

Python Programs

Three complete programs: fixed letters, input(), and a ch * repeat shortcut. Use View Output to reveal sample results.

Example 1 — Fixed 'E' down to 'A'

Hard-coded range — outer letter counts down; inner loop grows and prints that letter.

Python
top = ord('E')

for i in range(top, ord('A') - 1, -1):
    for j in range(top, i - 1, -1):
        print(chr(i), end="")
    print()

How It Works

1. Outer loop picks the letter. i runs from ord('E') down to ord('A').

2. Inner loop sets the width. j runs from top down to i — once for E, twice for D, and so on.

3. Print the outer letter. print(chr(i), end="") keeps the whole row the same character.

4. Break the line. Bare print() after the inner loop starts the next row.

Example 2 — User Input Version

Compute top = ord('A') + rows - 1, then grow repeat from 1 as letters count down. Prefer try/except ValueError in real apps.

Python
raw = input("Enter the number of rows: ").strip()

try:
    rows = int(raw)
except ValueError:
    print("Please enter a whole number of rows >= 1.")
else:
    if rows < 1:
        print("Please enter a whole number of rows >= 1.")
    else:
        if rows > 26:
            rows = 26

        top = ord('A') + rows - 1
        repeat = 1

        for code in range(top, ord('A') - 1, -1):
            ch = chr(code)
            for k in range(repeat):
                print(ch, end="")
            print()
            repeat += 1

How It Works

1. Prompt and parse. Ask for a row count, then convert with int(...) inside try/except ValueError.

2. Compute the top letter. For rows = 4, top is ord('D') — first row is D.

3. Grow the repeat count. Start at repeat = 1 and increment after each row so widths become 1, 2, 3, 4.

4. Clamp for A–Z. Cap at 26 so codes stay in the alphabet for demos.

Example 3 — ch * repeat

Build each repeated-letter row in one call — same shape, no explicit character loop.

Python
rows = 5
top = ord('A') + rows - 1
repeat = 1

for code in range(top, ord('A') - 1, -1):
    print(chr(code) * repeat)
    repeat += 1

How It Works

1. Same countdown. Still walk code from top down to ord('A').

2. Build the row. chr(code) * repeat creates a string of length repeat filled with that letter.

3. Learn loops first. Use Examples 1–2 when you need to show nested bounds; treat this as a polish shortcut afterward.

Edge Cases & Pitfalls

Check these before calling the solution done.

print(j)

Stepping letters on a row

If you print chr(j) instead of chr(i), letters change across the row. Print the outer letter to keep each row uniform.

step +1

Forward triangle by mistake

Counting letters upward reprints Program 9. Keep range(..., -1) from the top letter down to 'A'.

print early

Column of letters

If bare print() (or default print(chr(i))) is inside the inner loop, each letter lands on its own line. Use end="" for letters; call print() only after the inner loop.

rows > 26

Past Z

ord('A') + rows - 1 leaves A–Z when rows > 26. Clamp or reject in interactive programs.

rows = 1

Single A

Output is just A — top and tip coincide. A good sanity check.

Bad input

Catch ValueError

Bare int(input()) raises on letters — wrap in try/except ValueError and require 1–26.

Time and Space Complexity

ProgramTimeExtra space
Nested loops (Examples 1–2)O(rows²)O(1)
ch * repeat (Example 3)O(rows²)O(rows) per temporary row string

Total letters = 1 + 2 + … + n = n(n + 1)/2 — still quadratic in n. Same totals as Program 11; only the print order of widths differs.

Key Takeaways

  • Rule: countdown letter i; print i with growing width 1, 2, 3, …
  • Reverse of Program 9: same growing widths — letters step down instead of up.
  • Break the row: call bare print() only after the inner loop.
  • Complexity: O(n²) time from the triangular letter count; O(1) extra space for nested loops.

One line: for i from the top letter down to 'A', print i for every j from top down to i, then print().

Frequently Asked Questions

Program 9 uses A, BB, CCC, ... (letters increase). Program 10 uses E, DD, CCC, ... (letters decrease) with the same growing repeat counts.
On the 4th row the outer-loop letter is B, and the inner loop runs four times, printing B each time.
The inner loop only controls how many times to print. Printing the outer letter keeps the row uniform; printing the inner counter would change letters across the row.
With for j in range(top, i - 1, -1), when i is near the top the range is short; as i moves toward A the range lengthens, so repeat counts grow 1, 2, 3, …
print(ch, end="") stays on the same line. print() ends the current line. Letters use end=""; the row break uses print() after the inner loop.
O(n²) where n is the number of rows. Total printed characters equal 1+2+…+n = n(n+1)/2.
Yes. print(ch * repeat) prints a full repeated-letter row in one call. Nested loops are better for learning; ch * repeat is a handy shortcut later.
Use a try/except ValueError around int(input()), or check raw.isdigit() before converting, then clamp rows between 1 and 26 so bad input does not walk past A.

Did you know?

This pattern is the reverse of Program 9: row widths still grow 1, 2, 3, …, but letters run backward (E, then D, then C, …). Print the outer loop letter inside the inner loop so each row stays uniform.

Next: Inverted Repeating Triangle

Keep countdown letters, but shrink widths from n down to 1.

Program 11 tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful