Shape Rule
Growing reverse rows
Row i prints i letters from top down.

Print a reverse alphabet right-angled triangle: each row has one more character than the previous, and letters go from a top letter down toward A — E, ED, EDC, EDCB, EDCBA. Same geometry as Program 1, but descending along the alphabet. Includes a live preview, worked Python examples, edge cases, and complexity.
Growing reverse rows
Row i prints i letters from top down.
Row length
for i in range(1, rows + 1): picks how many letters each row prints.
Always from top
range(top, top - i, -1) prints descending codes from top.
Letter codes
top = ord('A') + rows - 1 then chr(code) for output.
1–10 rows
Pick a row count and draw the reverse triangle instantly in the browser.
Complexity
Triangular letter count: n(n+1)/2 prints.
A reverse alphabet right-angled triangle grows like Program 1, but every row starts at a fixed top letter and counts downward until a row-specific end letter.
In Python you solve it with nested for loops and range(..., -1): the outer loop picks the row length, the inner loop prints letter codes from top down, then print() moves to the next line.
It locks in reverse iteration with range step -1 — the same skill used in reverse triangles, diagonals, and mirrored alphabet labs.
1, 2, 3, … letters per row.
Inner loop restarts at the top letter.
range(top, top - i, -1) counts down.
Same triangle; opposite letter direction.
In short: for each row i from 1 to rows, print top..top-i+1 with print(chr(code), end=""), then call print().
Given a positive integer rows, print a left-aligned reverse alphabet right-angled triangle of letters with rows lines.
# First 5 rows (conceptual shape)
# E
# ED
# EDC
# EDCB
# EDCBA | Item | Type | Description |
|---|---|---|
rows | int | Number of triangle lines to print (typically ≥ 1). |
top | int (code) | Top letter code: ord('A') + rows - 1. |
| Printed output | text | Growing reverse prefixes from top down to A on the last row. |
top = ord('A') + rows - 1
for i from 1 to rows:
for code from top down to top - i + 1:
print letter (no newline)
print newline | Approach | Idea | Best for |
|---|---|---|
range(..., -1) | Outer row length + inner descending codes | Learning and interviews |
| Char outer loop | Walk end letter from top down to A | Matching classic E…EDCBA samples |
| Goal | Pattern |
|---|---|
| Top letter | top = ord('A') + rows - 1 |
| Walk each row | for i in range(1, rows + 1): |
| Print descending | for code in range(top, top - i, -1): print(chr(code), end="") |
| End the row | print() |
| Forward triangle | See Program 1 |
| Lowercase | Use ord('a') as the base instead of ord('A') |
Same triangle idea as Program 1 — only letter direction changes.
letterPrints each descending letter on the current row
breakEnds the row after top..end finishes
top..downInner loop uses range(..., -1)
A..endInner loop counts up from A
Reach for this when teaching reverse character loops on a growing triangle.
Keep the triangle; flip letter direction to descending.
Practice range(top, stop, -1) and stopping before top - i.
Next you change only the starting letter while counting forward.
Practice top = ord('A') + rows - 1 for any height.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one bound change (range(..., -1)) turns a forward triangle into a reverse one.
Choose between 1 and 10 rows and draw the reverse alphabet triangle in the browser.
Three complete Python programs — fixed row count, CLI input, and a spaced-letter variant. Click View Output to reveal sample console results.
Print five reverse rows with nested loops and range(..., -1).
rows = 5Hard-coded height — ideal for first demos and screenshots.
rows = 5
top = ord('A') + rows - 1
for i in range(1, rows + 1):
for code in range(top, top - i, -1):
print(chr(code), end="")
print() When i = 1, the inner loop prints E. When i = 3, it prints EDC, and so on through five letters on the last row. print() after the inner loop starts the next row.
Let the user choose the height at runtime.
Read the row count with input() and clamp with max(1, min(rows, 26)) (wrap in try/except ValueError in real apps).
rows = int(input("Enter the number of rows: "))
rows = max(1, min(rows, 26))
top = ord('A') + rows - 1
for i in range(1, rows + 1):
for code in range(top, top - i, -1):
print(chr(code), end="")
print() Same ord/chr core as Example 1; only the source of rows changes. For 4 rows, top becomes ord('D'). Non-numeric input raises ValueError with bare int(input()) — use try/except for safer labs.
Same reverse triangle with spaces between letters.
Print a trailing space after each letter so columns are easier to scan.
rows = 5
top = ord('A') + rows - 1
for i in range(1, rows + 1):
for code in range(top, top - i, -1):
print(chr(code) + " ", end="")
print() Loop bounds are unchanged — only the printed unit becomes chr(code) + " ". Trim trailing spaces later if you need a compact line.
Set rows (fixed or from input()). Compute top = ord('A') + rows - 1.
for i in range(1, rows + 1): selects how many letters print on the current line.
for code in range(top, top - i, -1): prints each letter with print(chr(code), end="").
print() ends the row so the next outer iteration starts fresh.
Total letters: 1+2+…+n = n(n+1)/2 — O(n²) time, O(1) extra memory.
rows = 5Trace each outer value of i and the descending codes the inner loop prints from top = E.
Row i | Inner range | Printed row | Letters this row |
|---|---|---|---|
1 | range(E, D, -1) | E | 1 |
2 | range(E, C, -1) | ED | 2 |
3 | range(E, B, -1) | EDC | 3 |
4 | range(E, A, -1) | EDCB | 4 |
5 | range(E, top-5, -1) | EDCBA | 5 |
*range stops before the end value, so top - 5 is below A and all five letters print. Total letter prints: 1 + 2 + 3 + 4 + 5 = 15 = 5×6/2.
Where this reverse triangle (and its descending loops) shows up beyond the homework prompt.
Clearest alphabet demo of counting letters downward with range(..., -1).
Example: flip bounds to Program 1 and compare.
Same triangle geometry — forward vs reverse fill.
Example: print both side by side for n = 5.
Practice computing top from a row count.
Example: rows 1..10 map to A..J.
Add separators without changing loop structure (Example 3).
Example: print chr(code) + " " for readable columns.
Triangular sums make O(n²) easy to see.
Example: 5 rows print 15 letters total.
Pair the pattern with try/except ValueError and clamp to 26.
Example: reject rows > 26 or clamp it.
Pro Tip: say “always start at top, print down for i letters” before coding — that story prevents wrong inner bounds.
Why this pattern earns a spot right after the forward alphabet triangle.
Wrong direction or bounds show up immediately as a non-reverse triangle.
Same structure; only loop direction and range step flip.
range(top, top - i, -1) is reusable in many Python patterns.
Streaming output needs no storage beyond loop counters.
Pro Tip: master Program 1 first; treat this page as the same story with arrows reversed.
Small habits that keep reverse-triangle code clean.
Every row starts from the same top letter; only the count changes with i.
range(top, top - i, -1)That triple is what produces E, ED, EDC, …
int(input()) in try/exceptAvoid crashes when the user types letters instead of a number.
Beyond Z you need a wrap/stop policy for top.
Trace EDC on paper before coding larger n.
Pro Tip: if every row starts with a different letter and runs forward to E, you wrote Program 3 — not this pattern.
Mistakes that commonly break reverse alphabet triangles.
range(start, start + i) prints Program 1 instead.
→ Use range(top, top - i, -1).
range(top, top - i) with default step +1 produces an empty range.
→ Always pass -1 as the third argument.
Each letter lands on its own line — you get a column, not a triangle.
→ Use print(..., end="") for letters; print() only after the inner loop.
Non-numeric input raises ValueError with bare int(input()).
→ Wrap in try/except ValueError and validate range.
Large rows makes top walk past Z.
→ Cap input at 26 or define a wrap policy.
Check these inputs before calling the solution done.
Output is just A on one line.
Through EDCBA.
Top is D → D…DCBA.
Reject, clamp, or wrap — decide explicitly.
int(input()) raises ValueError — validate first.
Same loops with ord('a') as the base.
Try these variations to lock in the pattern.
chr(code) + " " (Example 3)*i.n(n+1)/2.top = ord('A') + rows - 1 to generalize any height.Quick Takeaway: start every row at the top letter, print down for i letters, then break the line — that is the whole triangle.
| Program | Time | Extra space |
|---|---|---|
| Fixed / input (Examples 1–2) | O(rows²) | O(1) |
| Spaced letters (Example 3) | O(rows²) | O(1) |
Row k prints k letters; summing 1..n gives n(n+1)/2 character writes.
The reverse alphabet right-angled triangle is a small nested-loop exercise with lasting payoff: fixed top letter, descending inner walk with range(..., -1), and growing row length. Master the classic E…EDCBA sample, then try user input and optional spacing.
Practice the three examples above, then continue to Program 3’s triangle where each row starts one letter earlier but still runs forward.
Compute a top letter, print top..top-i+1 on each row, and break only after the inner loop finishes.
top every rowrange(top, top - i, -1) for descending outputtop = ord('A') + rows - 1int(input()) in try/except ValueError and cap at 26range(start, start + i) bounds for this pattern-1 step in the inner rangeprint() inside the inner letter looprows exceed 26 without a policyPrint the reverse alphabet right-angled triangle the beginner-friendly way.
Growing reverse prefixes
DefinitionInner always starts here
CodeCounts down to top-i
CodeEnds each row
I/OO(n²) time
AnalysisRow i prints i letters from the top letter down. For 5 rows the output is E, ED, EDC, EDCB, EDCBA — the descending mirror of Program 1. Total letters = n(n+1)/2.
Next up: each row starts one letter earlier, but letters still run forward to the top.
12 people found this page helpful