Python Reverse Alphabet Triangle Pattern (Fixed Start)

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

What Is This Pattern?

A reverse fixed-start alphabet triangle always begins each row at the same top letter and counts down, while the stopping letter rises so the reverse tail gets shorter.

Remember
Rule: for stop letter i from A to last,
      print last down through i

EDCBA
EDCB
EDC
ED
E         ← 5 rows (left edge fixed at E)

Same widths as Program 7 (5, 4, 3, 2, 1), but Program 7 moves the left edge (EDCBA, DCBA, …). Here the left edge stays put. Compare also with Program 5, which shrinks forward prefixes from A.

How to Solve It

Two ways to emit the same shape — start with nested letter loops, then optionally reverse a prefix once and take shorter leading slices.

MethodIdeaBest for
Nested letter loopsOuter = rising stop; inner = top..stop downwardLearning, interviews, exams
Reverse + top[:len]Build EDCBA… once, take shorter prefixesShorter demos once loops click

Pseudocode

Pseudocode
top = lastLetter
for stop from 'A' to top:
    for ch from top down to stop:
        print ch (no newline)
    print newline

Cheat sheet

GoalPattern
Raise stop letterfor i in range(ord('A'), top + 1):
Print top..i reversefor j in range(top, i - 1, -1): print(chr(j), end="")
End the rowprint()
Top letter from rowstop = ord('A') + rows - 1
One-line row shortcutReverse the A…top prefix, then top[:length] while length shrinks
Moving left edgeProgram 7 — start at i, print down to A

Printing Letters vs Starting a New Line

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

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

Live Preview

Change the row count and the reverse fixed-start triangle updates instantly — capped at 26 letters (A–Z).

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

Live result 5 rows · 15 letters
EDCBA
EDCB
EDC
ED
E

Worked Walkthrough — rows = 4

Trace each outer-loop stop letter as i rises from 'A' to 'D' with top fixed at 'D'.

Stop iInner jPrinted rowLetters
'A'D..ADCBA4
'B'D..BDCB3
'C'D..CDC2
'D'D..DD1

Total letter prints: 4 + 3 + 2 + 1 = 10 = 4×5/2 — same triangular count as Programs 5 and 7.

Python Programs

Three complete programs: fixed top letter, row-count input(), and a reverse-slice shortcut. Use View Output to reveal sample results.

Example 1 — Fixed top at 'E'

Hard-coded top letter — every row starts at E; the stop letter rises to shorten the tail.

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

How It Works

1. Outer loop raises the stop. i runs from ord('A') to ord('E') — longest row first.

2. Inner loop always starts at E. For each stop, j runs from E down to i, so the row is E..i in reverse.

3. Print letters, then break the line. print(chr(j), end="") stays on the row; bare print() after the inner loop starts the next (shorter) row.

When i is A you get EDCBA; when i is E you get E.

Example 2 — User Input Version

Read the row count at runtime. Prefer try/except and clamp to 26 (shown in the tip below).

Python
rows = int(input("Enter the number of rows: "))
top = ord('A') + rows - 1

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

How It Works

1. Prompt and read. Ask for a row count, then convert the line to an int.

2. Map rows to a top letter. top = ord('A') + rows - 1 — for rows = 4, top is ord('D').

3. Same fixed-start core. Only the source of top changes — the print logic matches Example 1.

4. Safer input tip. Prefer:

Safer input
try:
    rows = int(input("Enter the number of rows: "))
except ValueError:
    print("Enter a whole number from 1 to 26.")
    raise SystemExit

if rows < 1 or rows > 26:
    print("Enter a whole number from 1 to 26.")
    raise SystemExit

Example 3 — Reverse + top[:length]

Build the first reverse row once, then take shorter leading prefixes — same shape, no nested letter loop.

Python
rows = 5
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
top = letters[:rows][::-1]

for length in range(rows, 0, -1):
    print(top[:length])

How It Works

1. Take and reverse the prefix. ABCDE reversed becomes EDCBA — the first printed row.

2. Shrink the leading slice. top[:5] is the full row; top[:4] drops the trailing A; and so on down to E.

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.

j = i

Program 7 by mistake

If the inner loop starts at i instead of top, you print EDCBA, DCBA, … Use for j in range(top, i - 1, -1).

stop at A

No shrinking

Stopping at A every time reprints the full reverse run. The stop must be the rising outer variable i.

print() early

Column of letters

If bare print() (or default print(chr(j))) sits 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 stop coincide. A good sanity check.

Bad input

ValueError on int()

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

Time and Space Complexity

ProgramTimeExtra space
Nested loops (Examples 1–2)O(rows²)O(1)
Reverse + slice (Example 3)O(rows²)O(rows) for the reversed prefix and temporary row strings

Total letters = n + (n - 1) + … + 1 = n(n + 1)/2 — quadratic in n. Same totals as Programs 5 and 7.

Key Takeaways

  • Rule: always start at the top letter; raise the stop i so each reverse row shortens.
  • vs Program 7: same widths — here the left edge stays fixed; there the left edge moves.
  • Break the row: call bare print() only after the inner loop.
  • Complexity: O(n²) time; O(1) extra space for nested loops.

One line: for stop i from A to the top letter, print top down through i, then print().

Frequently Asked Questions

Because the inner loop always starts at the top letter (E in the 5-row example) and counts down. So the first printed character each row is always E.
The outer loop increases the stopping point for the inner loop. That shortens the tail each row, producing EDCBA, then EDCB, then EDC, and so on.
Program 7 changes the first letter each row (E, then D, then C…). Program 8 keeps the first letter fixed and only shortens the reverse tail.
Program 5 prints forward prefixes from A (ABCDE, ABCD, …). This pattern prints reverse prefixes from a fixed top (EDCBA, EDCB, …). Same shrinking widths; opposite letter direction and left edge.
Every row would print the full reverse run (EDCBA each time) with no shrinking. The stop must be the rising outer variable.
print(chr(j), 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²) for n rows, because total printed characters are n(n+1)/2.
Yes. Reverse the A…top prefix, then print top[:length] while length shrinks from rows down to 1. Nested ord/chr loops are better for learning; slicing is a handy shortcut later.
Prefer try/except ValueError around int(input()) and clamp rows between 1 and 26 so bad input does not walk past Z.

Did you know?

Every row begins with the same top letter because the inner loop always starts there. The outer loop only raises the stopping point, so the tail shortens: EDCBA, EDCB, EDC, ED, E. Same widths as Program 7, but the left edge stays fixed.

Next: Repeating Alphabet Triangle

Print the same letter repeatedly on each growing row.

Program 9 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