Shape Rule
One letter, growing count
Row 1 prints A, row 2 prints BB, row 3 prints CCC, row 4 prints DDDD, row 5 prints EEEEE.

Row 1 is one A, row 2 is two Bs, row 3 three Cs, and so on: A, BB, CCC, DDDD, EEEEE. Contrast Program 1, where letters change inside each row. Here, the row letter stays the same and only the count grows. Next up: Program 10 reverses the letter order. Includes a live preview, worked Python examples, edge cases, and complexity.
One letter, growing count
Row 1 prints A, row 2 prints BB, row 3 prints CCC, row 4 prints DDDD, row 5 prints EEEEE.
Row letter
for row in range(1, rows + 1): picks both the letter offset and how many times to repeat it on each line.
Count only
for _ in range(row): print(ch, end="") prints the same letter row times — the inner loop only controls count, not which letter.
ch * row
print(ch * row) repeats the letter in one line — same output as nested loops.
Rows 1–26
Pick a row count and draw A, BB, CCC live.
Complexity
1+2+…+n printed characters total.
A repeating-letter alphabet pattern (A, BB, CCC, ...) prints one letter per row, repeated as many times as the row number. With five rows the console shows A, BB, CCC, DDDD, EEEEE — unlike Program 1, where letters change inside each row.
In Python you solve it with two nested for loops: compute ch = chr(ord('A') + row - 1), repeat that letter row times with the inner loop, then call print() for the next line. Or shorten each row to print(ch * row).
It teaches that the inner loop can control repetition count while the outer loop picks the value — a key idea before Program 10’s reverse variant.
ch = chr(ord('A') + row - 1)
for _ in range(row) — count only.
print(ch, end="") then print().
A, BB, CCC, …
In short: for each row from 1 to rows, set ch = chr(ord('A') + row - 1), print ch exactly row times with print(ch, end=""), then call print().
Given a positive integer rows, print a left-aligned repeating-letter alphabet pattern: each row prints one letter repeated row times (A, BB, CCC when rows = 5).
# First 5 rows (conceptual shape)
# A
# BB
# CCC
# DDDD
# EEEEE | Item | Type | Description |
|---|---|---|
rows / top | int / char | Number of rows; last letter is 'A' + rows - 1 (E for 5). |
| Printed output | text | Growing rows of repeated letters A, BB, CCC, … |
base = ord('A')
for row from 1 to rows:
ch = chr(base + row - 1)
repeat ch exactly row times (inner loop or ch * row)
print() | Approach | Idea | Best for |
|---|---|---|
| Char nested loops | Outer i++, inner count, print i | Matching this classic sample |
| Row index + char math | ch = (char)('A' + row - 1) then print row times | User-input versions; clearer count |
| Goal | Pattern |
|---|---|
| Walk each row | for row in range(1, rows + 1): |
| Row letter | ch = chr(ord('A') + row - 1) |
| Repeat letter | for _ in range(row): print(ch, end="") |
| End the row | print() |
| One-line shortcut | print(ch * row) |
| Stepping letters variant | See Program 1 — A, AB, ABC triangle |
| Reverse repeat variant | See Program 10 (E, DD, CCC, …) |
ch * row vs print_row helperSame A, BB, CCC shape — three ways to think about row letter and repetition count.
for _ in range(row)Classic ord/chr loop — teaches letter formula and repetition count separately
print(ch * row)String multiplication — compact one-liner per row
def print_row(ch, n)Extract inner loop into a function — reusable for other patterns
loops firstMaster nested loops before the string shortcut or helper
Reach for this when teaching that the inner loop can control count while the outer variable controls the printed value.
Keep the same loop bounds; change only print(chr(j), end="") to print(chr(i), end="").
Practice decoupling “what to print” from “how many times.”
Next keeps repeats but walks the letter backward: E, DD, CCC.
Map row numbers to letters with 'A' + row - 1.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: printing the outer letter inside the inner loop is the cleanest way to build a growing triangle of repeated characters.
Choose 1–26 rows and draw the repeating-letter alphabet triangle in the browser.
Three complete Python programs — fixed A–E, user-chosen row count, and a chr(...) * row shortcut. Click View Output to reveal sample console results.
Print five growing rows of repeated letters from A to E.
rows = 5Hard-coded height — ideal for first demos and screenshots.
rows = 5
base = ord('A')
for row in range(1, rows + 1):
ch = chr(base + (row - 1))
for _ in range(row):
print(ch, end="")
print() When row = 1, ch is A and the inner loop prints it once. When row = 3, ch is C and the inner loop prints CCC. When row = 5, ch is E and the row is EEEEE. print() after the inner loop starts the next row.
Let the user choose how many rows to print.
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')
for row in range(1, rows + 1):
ch = chr(base + (row - 1))
for _ in range(row):
print(ch, end="")
print() For row 4, ch becomes D and the inner loop prints it four times. Cap rows at 26 so ch stays within A–Z.
Same shape with Python string multiplication.
ch * row String RepetitionMultiply the row letter by the row number — same triangle, one print per row.
rows = 5
rows = max(1, min(rows, 26))
base = ord('A')
for row in range(1, rows + 1):
ch = chr(base + (row - 1))
print(ch * row) chr(ord('A') + row - 1) * row builds each line in one expression. Keep the nested-loop version for exams that ask you to show outer vs inner letter logic.
i runs from 'A' to top. That’s the character printed on the row.
j runs from 'A' to i, so it executes 1, 2, 3, … times as rows grow.
Printing i keeps the whole row the same letter. Printing j would change letters across the row (Program 1).
print() ends each row before the next letter begins.
Total prints are 1+2+…+n for n rows, so time complexity is O(n²).
rows = 5Trace each outer-loop row value and see how the letter formula and repetition count produce each printed line.
row | Letter | Count | Output |
|---|---|---|---|
1 | A | 1 | A |
2 | B | 2 | BB |
3 | C | 3 | CCC |
4 | D | 4 | DDDD |
5 | E | 5 | EEEEE |
Highlight rows 1, 3, and 5: A ×1 → A; C ×3 → CCC; E ×5 → EEEEE. Total letter prints: 1 + 2 + 3 + 4 + 5 = 15 = 5×6/2.
Where this repeating-letter alphabet triangle shows up beyond the homework prompt.
Clearest demo of printing the outer variable inside the inner loop.
Example: change print(chr(i), end="") to print(chr(j), end="") and compare with Program 1.
Build intuition for loops that only control iteration count.
Example: rewrite the inner loop as for (int k = 0; k < n; k++).
Map row indexes to letters with 'A' + row - 1.
Example: scale from 5 to 8 without rewriting loops.
Later rewrite as new string(ch, row) once the idea clicks.
Example: same output with one print per row.
Triangle sums make O(n²) easy to see.
Example: 15 letters for 5 rows.
Sits between Programs 8 and 10 in the alphabet set.
Example: revisit Program 1.
Pro Tip: say “pick the letter outside, repeat it inside” before coding — that story prevents printing j by habit.
Why this pattern earns a spot early in the alphabet-pattern series.
A stepping-letter row (ABC) shows immediately if you printed j.
Only the printed variable changes.
Change the top letter or row count and the whole triangle grows.
No padding or diagonal checks — just two loops and one print rule.
Pro Tip: master Program 1 first; this page is mostly “same loops, print the outer letter.”
Small habits that keep repeating-letter alphabet triangles clean.
Printing j turns this into Program 1.
Do not increment the character inside the inner loop.
Keep the row letter inside A–Z when taking user input.
Validate the row count before using int(input()).
Use ch = (char)('A' + row - 1) when working with integer row indexes.
Pro Tip: if you see A, AB, ABC, you printed j — switch back to print(chr(i), end="").
Mistakes that commonly break repeating-letter alphabet triangles.
Using chr(base + row) skips A on row 1 or starts at B. Forgetting row - 1 shifts every letter forward.
→ Always use ch = chr(base + (row - 1)) with 1-based row values.
range(rows) starts at 0, so chr(base + row - 1) on row 0 gives wrong letters or an extra blank row.
→ Use for row in range(1, rows + 1): so row matches both letter offset and repeat count.
Row 27 would need a letter beyond Z — chr() still returns a character but not the expected alphabet pattern.
→ Clamp with rows = max(1, min(rows, 26)) after reading input.
Printing a changing letter inside the inner loop produces A, AB, ABC — Program 1, not this pattern.
→ Print the same ch every time in the inner loop, or use print(ch * row).
Omitting print() glues every letter onto one endless line.
→ Always end the row after the inner loop (unless using print(ch * row) alone).
Check these inputs before calling the solution done.
Output is just A.
A through EEEEE (Example 1).
Ends at DDDD (Example 2).
Cap or reject — the row letter leaves the alphabet.
Validate with try/except ValueError.
Swap 'A' for 'a' as the base.
Try these variations to lock in the pattern.
print(chr(i), end="") to print(chr(j), end="")new string(ch, row)i (not j) is what keeps each row uniform.Quick Takeaway: choose the row letter in the outer loop, then print that letter once per inner iteration — that alone builds A, BB, CCC, …
| Program | Time | Extra space |
|---|---|---|
| Inline / input (Examples 1–2) | O(n²) | O(1) |
chr(...) * row (Example 3) | O(n²) | O(1) |
For n rows you print 1+2+…+n = n(n+1)/2 characters, so total work is O(n²).
The repeating-letter alphabet triangle is Program 1 with a different print rule: the outer loop picks the letter, and the inner loop only repeats it. Master the classic A…EEEEE sample, then try user input and the multiplication shortcut.
Practice the three examples above, then continue to Alphabet Pattern 10.
Outer row letter from ord('A') to top; inner loop counts repeats; print chr(i) each time, then print() for the newline.
i or ch) inside the inner loopch = (char)('A' + row - 1) for integer row indexesj when you want A, BB, CCC- 1 in the letter formulaprint() inside the letter loopPrint the repeating-letter alphabet triangle the beginner-friendly way.
One letter, growing repeats
Definitionprint(chr(i), end=""), not print(chr(j), end="")
CodeControls count only
ShapeSame loops, different print
CompareO(n²) time
AnalysisEach row prints one letter repeated row times: row 1 is A, row 2 is BB, row 3 is CCC. Letter = chr(ord('A') + row - 1). Compare Program 10 (reverse repeated letters) and Program 1 (classic A.. triangle).
Reverse repeating triangle — the next alphabet pattern in the series.
12 people found this page helpful