Shape Rule
Fixed top, shifting stop
Row 0 prints EDCBA, row 1 prints DCBA, row 2 prints CBA, down to a single A on the last row.

The reverse alphabet pattern prints descending letters on each row, from a fixed top letter down to a row-specific stop. This tutorial covers the shape rule, fixed top formula, reverse range step, a live preview, algorithm steps, worked Python examples, edge cases, and complexity.
Fixed top, shifting stop
Row 0 prints EDCBA, row 1 prints DCBA, row 2 prints CBA, down to a single A on the last row.
Row index
for i in range(rows): picks the stop letter for each row — A on row 0, B on row 1, up to the top letter on the last row.
top down to stop
for code in range(top, stop - 1, -1): prints descending letters from the fixed top down to the row stop.
Same line / next line
Letters use print(..., end=""); end each row with print().
1–26 rows
Pick a row count and draw the fixed-top reverse alphabet pattern instantly in the browser.
Complexity
Total letters = n(n+1)/2; extra memory stays O(1).
A reverse alphabet pattern (EDCBA to E) prints descending letters on each row — every row starts at the same top letter while the stop moves up each line. With five rows the console shows EDCBA, EDCB, EDC, ED, E — the fixed-top mirror of Program 7’s shrinking-start shape.
In Python you solve it with two nested for loops: compute top = ord('A') + rows - 1, set stop = ord('A') + i per row, print letters with range(top, stop - 1, -1), then call print() for the next line.
It teaches per-row descending bounds with a fixed start at the top letter — the natural follow-up after Program 7. Once stop = base + i and range(top, stop - 1, -1) click, slice shortcuts and Program 9 follow naturally.
top = ord('A') + rows - 1 — for five rows, every row starts at E.
Row i stops at chr(base + i) — A, then B, then C, up to the top letter on the last row.
range(top, stop - 1, -1) counts down; print(chr(code), end="") then print().
Program 7 shrinks EDCBA, DCBA, CBA; this pattern keeps E on the left and shifts the stop — compare both side by side.
In short: for each row i from 0 to rows - 1, set stop = ord('A') + i, print letters from fixed top down to stop with range(top, stop - 1, -1) and print(chr(code), end=""), then call print().
Given a positive integer rows, print a left-aligned reverse alphabet pattern: each row prints descending letters from a fixed top letter down to a row-specific stop (EDCBA when rows = 5).
# First 5 rows (conceptual shape)
# EDCBA
# EDCB
# EDC
# ED
# E | Item | Type | Description |
|---|---|---|
rows | int | Number of pattern lines to print (typically ≥ 1). |
top | int (code) | Fixed start letter on every row: ord('A') + rows - 1. |
| Printed output | text | Left-aligned rows; row i prints from chr(top - i) down to A. |
top = ord('A') + rows - 1
for i from 0 to rows - 1:
stop = base + i
for code from top down to stop (step -1):
print letter (no newline)
print newline | Approach | Idea | Best for |
|---|---|---|
| Nested reverse loops | Fixed top + shifting stop | Learning and interviews |
| Fixed top formula | top = ord('A') + rows - 1 | This pattern — shared first letter every row |
letters[i:rows][::-1] | Slice from row index to top, then reverse | Shorter production-style demos |
| Goal | Pattern |
|---|---|
| Fixed top letter | top = ord('A') + rows - 1 |
| Walk each row | for i in range(rows): |
| Row stop letter | stop = base + i |
| Print top down to stop | for code in range(top, stop - 1, -1): print(chr(code), end="") |
| End the row | print() |
| One-line row shortcut | print(letters[i:rows][::-1]) |
| Shifting stop variant | See Program 7 — rows end at A |
Same EDCBA-to-E shape — three ways to think about descending row bounds.
range(top, stop-1, -1)Classic ord/chr loop — teaches fixed top, shifting stop, and step -1
letters[i:rows][::-1]Prefix slice then reverse — compact one-liner per row
''.join(reversed(...))Readable alternative to [::-1] for the same row string
loops firstMaster nested reverse loops before the string shortcut
Reach for this pattern when teaching descending letter bounds with a fixed top letter — the natural follow-up after Program 7’s shrinking-start shape.
Natural follow-up after Program 6 — same row count, every row starts at the top letter while the stop shifts up.
Practice range(top, stop - 1, -1) with an immediate visual check.
Combine loops with input() for a flexible row count.
Leads to reverse patterns, pyramids, and hollow shapes in the series.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one small program that locks in a fixed top letter, a rising floor, reverse range step, output sequencing, and O(n²) thinking — the fixed-start step after Program 7.
Choose a row count between 1 and 26 and draw the fixed-top reverse alphabet pattern in the browser.
Three complete Python programs — fixed row count, CLI input, and a letters[i:rows][::-1] shortcut. Click View Output to reveal sample console results.
Print five rows with classic nested reverse loops — fixed top, shifting stop.
rows = 5Hard-coded height — ideal for first demos and screenshots.
rows = 5
base = ord('A')
top = base + rows - 1 # 'E' when rows = 5
for i in range(rows):
stop = base + i
for code in range(top, stop - 1, -1):
print(chr(code), end="")
print() When i = 0, stop is A and the inner loop prints EDCBA. When i = 2, stop is C and the row is EDC. When i = 4, stop is E, so the last row is a single E. print() after the inner loop starts the next row.
Let the user choose the height at runtime.
Read the row count with input() and convert with int() (wrap in try/except ValueError in real apps).
rows = int(input("Enter the number of rows (max 26): "))
rows = max(1, min(rows, 26))
base = ord('A')
top = base + rows - 1
for i in range(rows):
stop = base + i
for code in range(top, stop - 1, -1):
print(chr(code), end="")
print() Same ord/chr core as Example 1; only the source of rows changes. The clamp keeps letter codes within A–Z. Non-numeric input raises ValueError with bare int(input()) — use try/except for safer labs.
Same shape without an explicit inner letter loop.
letters[i:rows][::-1]Slice from row index i to the top letter, then reverse for each row.
rows = 5
rows = max(1, min(rows, 26))
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(rows):
print(letters[i:rows][::-1]) letters[i:rows] returns letters from index i up to index rows. With rows = 5, row 0 is letters[0:5][::-1] = EDCBA, row 2 is letters[2:5][::-1] = EDC, and so on. Keep the two-loop version for exams that ask you to show reverse bounds and step -1.
Use input() when reading input. Set rows (fixed or from CLI), clamp to 1–26, and compute top = ord('A') + rows - 1.
for i in range(rows): selects the stop letter for the current line — A on row 0, B on row 1, up to the top letter on the last row.
stop = base + i then for code in range(start, base - 1, -1): prints each letter with print(chr(code), end="").
print() ends the row so the next outer iteration starts fresh.
Total letters: n+(n-1)+…+1 = n(n+1)/2 — O(n²) time, O(1) extra memory.
rows = 5Trace each outer-loop value i (0-based) and see what the inner loop prints from fixed top down to row stop.
Outer i | top | stop | range | Printed row | Letters this row |
|---|---|---|---|---|---|
0 | E | A | range(69, 64, -1) | EDCBA | 5 |
1 | E | B | range(69, 65, -1) | EDCB | 4 |
2 | E | C | range(69, 66, -1) | EDC | 3 |
3 | E | D | range(69, 67, -1) | ED | 2 |
4 | E | E | range(69, 68, -1) | E | 1 |
Total letter prints: 5 + 4 + 3 + 2 + 1 = 15 = 5×6/2. Same triangular total as Programs 1, 4, 5, and 7 — only the letter bounds per row differ.
Where this fixed-top reverse descending letter pattern (and its shifting stop) shows up beyond the homework prompt.
Clearest visual proof that range(top, stop - 1, -1) counts down from a fixed top letter while stop moves forward each row.
Example: compare side-by-side with Program 7.
Natural step after Program 7 before Program 9’s repeating-letter variant.
Example: Program 9 prints A, BB, CCC, and so on.
Practice reverse character loops and print(..., end="")/print() with a shape that differs visibly from Program 6 and 7.
Example: compare Program 6 ascending vs Program 7 shrinking-start vs this fixed-top shape.
Swap to lowercase or digits once the letter loop works.
Example: print lowercase a..z once uppercase clicks.
Triangular totals make O(n²) concrete for beginners.
Example: count printed letters for n = 10 → 55.
Pair the pattern with try/except ValueError and positive-row checks.
Example: reject rows <= 0 and re-prompt.
Pro Tip: when an interviewer asks for descending letters per row, explain that stop = base + i and the inner loop uses step -1 down to A.
Why this reverse descending pattern earns a spot after Program 7 in beginner Python courses.
Side-by-side with Program 7 makes fixed top vs shrinking start obvious.
Only loops and console output — no arrays or math libraries.
One formula change flips between Program 7’s shrinking start and this shifting stop shape.
Streaming output needs no storage beyond loop counters.
Pro Tip: master Program 7 first, then this page — the row count is the same; only whether the start or stop moves changes the shape.
Small habits that keep reverse alphabet-pattern code clean.
Set top = ord('A') + rows - 1 before the outer loop — don’t recalculate every row. Set stop = base + i inside the outer loop.
int(input()) in try/exceptAvoid crashes when the user types letters instead of a number.
Only call print() after the inner loop finishes the row.
range(top, stop - 1, -1) needs step -1 and stop stop - 1 so the row stop letter is included.
Trace rows = 3 on paper — expect CBA, CB, C — before coding larger demos.
Pro Tip: if rows print in ascending order, you almost certainly forgot step -1 in the inner range.
Mistakes that commonly break fixed-top reverse alphabet patterns.
range(top, stop - 1) without -1 fails or prints nothing — descending loops need an explicit negative step.
→ Use range(top, stop - 1, -1) so letters count down to the row stop.
Using range(top, stop) stops before the row stop letter — the last letter on each row is missing.
→ Stop at stop - 1 (one below the row stop) so the stop letter is included when stepping by -1.
Omitting print() after the inner loop glues every letter onto one endless line.
→ Always end the row after the inner loop.
Non-numeric input raises ValueError with bare int(input()).
→ Wrap in try/except ValueError and validate range.
Program 7 shrinks the start each row but ends at A (EDCBA, DCBA). Program 6 prints ascending rows ending at a fixed top letter — not the same as EDCBA-to-E.
→ This pattern: fixed top, stop = base + i, range(top, stop - 1, -1), every row starts at the top letter.
Check these inputs before calling the solution done.
Output is just the top letter — stop equals top and the inner loop prints one letter.
Outer loop never runs — print nothing or show a message.
rows < 0Treat as invalid; re-prompt instead of silent empty output.
Output grows as n²/2 characters — fine for labs, noisy for huge n.
int(input()) raises ValueError — validate first.
On the last row, stop == top — inner loop prints one letter only.
Try these variations to lock in the fixed-top reverse pattern.
rowschr(code) with digit logictry/except ValueError until rows >= 1top = ord('A') + rows - 1 is computed once — for five rows every row starts at E.range(top, stop - 1, -1) needs step -1 and stop stop - 1 so the row stop letter is included.rows > 0 for interactive programs; rows = 1 should print a single top letter.Quick Takeaway: compute fixed top, shift stop each row, print with range(top, stop - 1, -1), then break the line.
| Program | Time | Extra space |
|---|---|---|
| Nested loops (Examples 1–2) | O(rows²) | O(1) |
letters[i:rows][::-1] (Example 3) | O(rows²) | O(rows) per row string (temporary) |
The reverse alphabet pattern (EDCBA to E) is a compact bounds exercise with lasting payoff: fixed top, fixed top, per-row shifting stop, reverse range, and O(n²) intuition. Master the classic two-loop version, then optionally shorten rows with letters[i:rows][::-1].
Practice the three examples above, then continue to Program 9 for the repeating-letter variant in the series.
Every row starts at the top letter — keep range(top, stop - 1, -1), use print(..., end="") for letters and print() for the break, and validate row counts when reading input.
top = ord('A') + rows - 1 once before the outer loopstop = base + i inside for i in range(rows):range(top, stop - 1, -1) and print(chr(code), end="")rows ≥ 1 for interactive programsint(input()) in try/except ValueError-1 on the inner rangerows = 1 edge casePrint EDCBA-to-E the beginner-friendly way.
Fixed top, shifting stop each row
Definitiontop = base + rows - 1
Codestop = base + i
Coderange(top, stop - 1, -1)
I/OO(n²) time
AnalysisAlphabet pattern A, BB, CCC, ... — the next alphabet pattern in the series.
12 people found this page helpful