Continuous Alphabet Triangle Pattern in Python

Beginner
⏱️ 6 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
sequential letters

What You'll Learn

This program prints a triangle where letters continue from row to row (they donโ€™t restart at A each time).

⭐ Pattern Output

When you run the program with rows = 5:

Output
A
B C
D E F
G H I J
K L M N O
1

Complete Python Program

Fixed rows = 5 version (no magic ASCII numbers):

Python
rows = 5

base = ord('A')
code = base

for row in range(1, rows + 1):
    letters = []
    for _ in range(row):
        letters.append(chr(code))
        code += 1
    print(" ".join(letters))

🧠 How It Works

1

Running letter counter

code = ord('A') tracks the next letter globally. It never resets between rows, so the alphabet continues across the whole triangle.

State
2

Build one row as a list

For each row, the inner loop runs row times, appending chr(code) and then doing code += 1.

Inner
3

Join with spaces

print(" ".join(letters)) prints the row with spaces between letters on a single line.

Output
=

Continuous triangle

Row r adds r letters, so total letters are n(n+1)/2O(n²) time; the list per row is O(row) auxiliary space.

2

Variation — User Input Version

Read rows from user input (clamped to 6 so we stay within A–Z):

Python
rows = int(input("Enter the number of rows (max 6): "))
rows = max(1, min(rows, 6))

code = ord('A')

for row in range(1, rows + 1):
    letters = []
    for _ in range(row):
        letters.append(chr(code))
        code += 1
    print(" ".join(letters))

💡 Tips for Enhancement

Try These

  • Print lowercase letters by starting from ord('a')
  • Change spacing (use "-".join(letters) or tabs)
  • Increase max rows by switching to a larger alphabet set (wrap-around or Unicode)

Avoid

  • Hardcoding ASCII values like 64 or 69
  • Letting rows exceed the alphabet size without defining behavior
  • Printing extra trailing spaces at the end of each row

Key Takeaways

1

Keep a running code value so letters continue across rows.

2

Each row prints row letters separated by spaces.

3

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

❓ Frequently Asked Questions

We keep a running letter code and increment it after each printed character, so the next row continues from where the previous row ended.
This pattern prints 1+2+…+n = n(n+1)/2 letters. rows = 7 would need 28 letters (past Z), but rows = 6 needs only 21.
It’s O(n²) for n rows, because the program prints 1+2+…+n letters in total.

Next: Python Alphabet Pattern 14

Continue to Program 14 for the odd-length alphabet row pattern.

Program 14 →

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