Alphabet Pattern (A, BB, CCC, DDDD, ...) in Python

Beginner
⏱️ 6 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
n(n+1)/2 letters total

What You'll Learn

This program prints an increasing repetition pattern: row 1 prints A, row 2 prints BB, row 3 prints CCC, and so on.

The letter advances by one each row, while the repetition count equals the row number.

⭐ Pattern Output

When you run the program with rows = 5:

Output
A
BB
CCC
DDDD
EEEEE
1

Complete Python Program (Nested Loops)

This version uses a nested loop to print each character one by one.

Python
rows = 5
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()

🧠 How It Works

1

One row per row

for row in range(1, rows + 1) visits rows 1 through rows. The letter for that row is chr(base + (row - 1)) (A, then B, then C, …).

Outer
2

Repeat the letter row times

The inner for _ in range(row) prints the same character row times on one line, giving A, BB, CCC, …

Inner
3

New line after each row

print(ch, end="") keeps letters on the same row; the bare print() after the inner loop starts the next row.

print
=

Growing repeats

You print 1+2+…+n = n(n+1)/2 characters, so runtime is O(n²) and memory beyond the output is O(1).

2

Variation — String Repetition (Concise)

Same output using Python's string * count repetition.

Python
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)

💡 Tips for Enhancement

Try These

  • Print lowercase letters using base = ord('a')
  • Print spaced output like A, B B, C C C
  • Start from a custom letter (e.g., start = 'D')

Avoid

  • Hardcoding ASCII values like 65 or 70
  • Allowing rows above 26 without wrap-around logic

Key Takeaways

1

Each row prints a single character repeated row times.

2

Use chr(base + offset) to move from A to B to C...

3

Total printed letters are \(n(n+1)/2\), so runtime is O(n²).

❓ Frequently Asked Questions

It prints 1+2+…+n = n(n+1)/2 letters in total.
Yes. Use base = ord('a') instead of ord('A').
Use string repetition: print(ch * count).

Next: Python Alphabet Pattern 10

Continue to Program 10 for the reverse repeated-letter pattern.

Program 10 →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful