Shape Rule
Wide first, letters forward
Row 1 prints AAAAA, then BBBB, down to a single E.

Row width shrinks from five to one, but the letter moves forward each row: AAAAA, BBBB, CCC, DD, E. Compare with Program 11 (same shape, letters step down) and worked Python examples, live preview, edge cases, and complexity.
Wide first, letters forward
Row 1 prints AAAAA, then BBBB, down to a single E.
Letter advance
for i in range(ord('A'), ord('E') + 1): picks the letter for each row.
Width 5…1
for j in range(ord('E'), i - 1, -1): shrinks as i rises — print chr(i), not the inner counter.
Same line / next line
Letters use print(..., end=""); end each row with print().
1–26 rows
Pick a row count and draw the inverted forward triangle in the browser.
Complexity
Total letters = n(n+1)/2; extra memory stays O(1).
An inverted forward repeating alphabet triangle starts wide and shrinks by one repeated letter on each new line, while letters advance from A toward the top of the range. With the right angle on the left, the console shows an upside-down staircase of identical letters per row.
In Python you usually solve it with two nested for loops: the outer loop picks the row letter (counting up), the inner loop prints that same letter fewer times each row, then print() moves to the next line.
It shows that letter direction and width direction are independent knobs. Flip only the outer loop (A→E vs E→A) and you move between Program 12 and Program 11 without rewriting the shape idea.
Top row repeats A exactly n times.
Rows go A, B, C, … while widths go n…1.
print(chr(i), end="") in the inner loop; print() after.
Same widths — opposite letter direction.
In short: for each letter i from A up to top, print i repeatedly (top - i + 1) times, then call print().
Given a positive integer rows (or a fixed top letter like 'E'), print a left-aligned inverted triangle where letters advance from A and widths shrink from rows down to 1.
# First 5 rows (conceptual shape)
# AAAAA
# BBBB
# CCC
# DD
# E | Item | Type | Description |
|---|---|---|
rows | int | Number of triangle lines (typically 1–26). Top letter = chr(ord('A') + rows - 1). |
| Printed output | text | Left-aligned rows; row r (0-based) prints letter chr(ord('A') + r) exactly rows - r times. |
for row from 0 to rows - 1:
ch = chr(ord('A') + row)
repeat = rows - row
for k from 1 to repeat:
print ch (no newline)
print newline | Approach | Idea | Best for |
|---|---|---|
| Nested char loops | Outer A…top + inner top…i width | Learning and interviews |
ch * repeat | Build a whole row in one call | Shorter production-style demos |
| Goal | Pattern |
|---|---|
| Walk letters forward | for i in range(ord('A'), ord('E') + 1): |
| Shrink repeat count | for j in range(ord('E'), i - 1, -1): |
| Print row letter | print(chr(i), end="") — not the inner counter |
| End the row | print() |
| One-line row shortcut | print(ch * repeat) |
| Letters step down | See Program 11 (EEEEE, DDDD, …) |
Same triangle — different ways to emit characters.
same linePrints a letter without moving to the next line
new lineEnds the current row after all repeats are printed
whole rowBuilds n copies of ch at once — skip the inner loop
print chr(i)Master printing the outer letter before the string shortcut
Reach for this triangle when practicing inverted widths with forward letters.
Keep shrinking widths; flip only the letter direction to A→E.
Letter direction and width direction can flip separately.
Practice ch = chr(ord('A') + row) and repeat = rows - row.
Next: sequential letters that keep advancing across rows.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one small program that proves letter direction is independent of inverted width — a core alphabet-pattern skill.
Choose a row count between 1 and 26 and draw the inverted forward repeating alphabet triangle in the browser.
Three complete Python programs — fixed top letter, CLI input, and a ch * repeat shortcut. Click View Output to reveal sample console results.
Print five inverted forward rows with classic nested char loops.
'A' up to 'E'Hard-coded range — ideal for first demos and screenshots.
for i in range(ord('A'), ord('E') + 1):
for j in range(ord('E'), i - 1, -1):
print(chr(i), end="")
print() When i is ord('A'), the inner loop runs from E down to A (5 times) and prints A. When i is ord('B'), it prints BBBB, and so on until a single E. Printing chr(i) (not the inner counter) keeps each row uniform.
Let the user choose the height at runtime.
Use row index: ch = chr(ord('A') + row) and repeat = rows - row. Wrap int(input()) in try/except ValueError in real apps.
rows = int(input("Enter the number of rows: "))
rows = max(1, min(rows, 26))
base = ord('A')
for row in range(rows):
ch = chr(base + row)
repeat = rows - row
for _ in range(repeat):
print(ch, end="")
print() For rows = 4, row 0 prints A four times, row 1 prints B three times, and so on. Clamp rows to 1–26 so letters stay within A–Z.
Same shape without an explicit inner print loop.
ch * repeatBuild each repeated-letter row in one call, then print it.
rows = 5
base = ord('A')
for row in range(rows):
ch = chr(base + row)
repeat = rows - row
print(ch * repeat) ch * repeat creates a string of length repeat filled with that letter. Great once you understand the nested-loop idea; keep the two-loop version for exams that ask you to show both bounds.
Use input() when reading input. Fix the top letter or compute it from rows.
for i in range(ord('A'), ord('E') + 1): selects the character printed on the row.
for j in range(ord('E'), i - 1, -1): runs 5, 4, 3… times; print chr(i) with print(chr(i), 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.
'A' up to 'E'Trace each outer-loop value of i and count how many times the inner loop runs.
i | Inner j range | Printed row | Repeats |
|---|---|---|---|
'A' | 'E'..'A' | AAAAA | 5 |
'B' | 'E'..'B' | BBBB | 4 |
'C' | 'E'..'C' | CCC | 3 |
'D' | 'E'..'D' | DD | 2 |
'E' | 'E'..'E' | E | 1 |
Total letter prints: 5 + 4 + 3 + 2 + 1 = 15 = 5×6/2.
Where this tiny pattern (and its loop structure) shows up beyond the homework prompt.
Clearest demo that forward letters can pair with shrinking widths.
Example: swap only the outer loop direction to get Program 11.
Teach letter direction as a one-line change.
Example: side-by-side EEEEE/DDDD vs AAAAA/BBBB.
Practice chr(ord('A') + row) and rows - row without char countdown tricks.
Example: row 2 → letter C, repeat = n-2.
Swap to lowercase or mix digits once the loops work.
Example: start from 'a' + row.
Descending triangular totals still make O(n²) concrete.
Example: 5+4+…+1 = 15 for n = 5.
Pair the pattern with try/except ValueError and 1–26 clamps.
Example: reject rows <= 0 or rows > 26.
Pro Tip: say “letters go up, width goes down” before coding — that story prevents mixing Program 11’s countdown letter with this page.
Why this pattern earns a spot right after the inverted countdown triangle.
Wrong letter direction shows up immediately as EEEEE instead of AAAAA.
Only loops, chars, and console output — no arrays required.
Flip to Program 11 by counting letters downward instead.
Streaming output needs no storage beyond loop counters.
Pro Tip: learn the nested-loop version first; treat ch * repeat as a polish shortcut afterward.
Small habits that keep alphabet-pattern code clean.
Use ch = chr(ord('A') + row) and repeat = rows - row — clearer than overloaded char bounds alone.
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.
For A–Z demos, reject or clamp rows > 26.
Trace rows = 3 (AAA, BB, C) on paper before coding larger demos.
Pro Tip: if you get EEEEE, DDDD, CCC instead of AAAAA, BBBB, CCC, you reused Program 11’s countdown outer loop.
Mistakes that commonly break inverted forward repeating alphabet patterns.
j Instead of iRows become countdown sequences instead of repeated letters.
→ Always print(chr(i), end="") (or ch) for this shape.
Counting i from top down to A prints EEEEE first instead of AAAAA.
→ Keep i (or row) advancing from A upward.
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 int(input()) in try/except ValueError and validate range.
chr(ord('A') + rows - 1) can leave the A–Z range.
→ Clamp to 26 or define wrap/error behavior explicitly.
Check these inputs before calling the solution done.
Output is just A on one line.
Treat as invalid; re-prompt instead of silent empty output.
rows < 0Invalid height — validate before looping.
Clamp or error — char math leaves A–Z.
Non-numeric input becomes 0 — check try/except ValueError first.
Same loops work with 'a' + row.
Try these variations to lock in the pattern.
try/except ValueError until 1 <= rows <= 26'a' + row as the row lettern(n+1)/2 — hence O(n²) time.1 <= rows <= 26 for interactive A–Z programs.Quick Takeaway: outer loop advances the letter (A→top), inner loop shrinks the width, then break the line — that is the whole pattern.
| Program | Time | Extra space |
|---|---|---|
| Nested loops (Examples 1–2) | O(rows²) | O(1) |
ch * repeat (Example 3) | O(rows²) | O(rows) per row string (temporary) |
The inverted forward repeating alphabet triangle is a small nested-loop exercise with lasting payoff: forward letters vs shrinking width, and O(n²) intuition. Master the classic two-loop version, then optionally shorten rows with ch * repeat.
Practice the three examples above, then compare with Program 11 or continue to Program 13’s sequential letters.
Print the outer letter with print(..., end=""), end rows with print(), and use repeat = rows - row (not Program 11’s countdown letter) for this shape.
print(chr(i), end="") for letters and print() after each row1 <= rows <= 26 for interactive programstry/except ValueError after input()print() inside the inner letter looprows > 26 without a clear policyPrint the inverted forward repeating triangle the beginner-friendly way.
Letters up, width down
DefinitionAdvances A→top
CodeShrinks with print(chr(i), end="")
Ends each row
I/OO(n²) time
AnalysisThis is the forward-letter twin of Program 11: same inverted widths (5…1), but letters advance A→E instead of stepping down. Print the outer loop letter inside the inner loop so each row stays uniform.
Next up: sequential letters that keep advancing across the whole triangle.
12 people found this page helpful