Reverse Repeated Alphabet Pattern (EEEEE to A) in Python

What You'll Learn
This program prints a reverse repeated-letter pattern where the letter decreases each row, and the repeat count decreases too.
With rows = 5, the top letter is E and the output becomes EEEEE, DDDD, CCC, BB, A.
⭐ Pattern Output
When you run the program with rows = 5:
EEEEE
DDDD
CCC
BB
AComplete Python Program (Nested Loops)
This version prints each character using a nested loop.
rows = 5
rows = max(1, min(rows, 26))
base = ord('A')
top = base + rows - 1
for row in range(rows, 0, -1):
ch = chr(base + (row - 1))
for _ in range(row):
print(ch, end="")
print()🧠 How It Works
Count row down from rows
for row in range(rows, 0, -1) gives row lengths 5, 4, 3, 2, 1 when rows = 5. The letter is chr(base + (row - 1)), so the top row is five Es.
Print row copies of one letter
The inner loop repeats the current letter exactly row times. As row shrinks, both width and letter code decrease.
Row break
After the inner loop, print() moves to the next line so each pattern row is separate.
Shrinking repeated rows
Again you print n(n+1)/2 characters total — O(n²) time, O(1) extra space.
Variation — String Repetition (Concise)
Same pattern using ch * count.
rows = 5
rows = max(1, min(rows, 26))
base = ord('A')
for row in range(rows, 0, -1):
ch = chr(base + (row - 1))
print(ch * row)💡 Tips for Enhancement
Try These
- Print lowercase using
base = ord('a') - Start from a fixed letter like
Zby settingtopmanually - Add spaces between characters for readability
Avoid
- Hardcoding ASCII values like
69and64 - Letting
rowsexceed 26 without wrap-around logic
Key Takeaways
For each row, compute the letter with chr(base + (row - 1)).
Use range(rows, 0, -1) to count rows downward.
Total printed letters are \(n(n+1)/2\), so runtime is O(n²).
❓ Frequently Asked Questions
rows = 5, the top letter is 'A' + (rows - 1), which is E. The first row repeats the current letter rows times.print(ch * count).Next: Python Alphabet Pattern 12
Continue to Program 12 for another repeated-letter variation.
10 people found this page helpful
