Python Alphabet Pattern Programs

Beginner
6 min read
Updated: Nov 2026
3 examples
print + end=""

Definition and Usage

A Python alphabet pattern is a script that prints letters in rows. The outer for loop chooses how many letters the row needs. The inner loop prints each letter with end="", then a bare print() ends that row.

A letter is a one-character string. 'A' + 1 raises TypeError, because Python will not add a str and an int. 'A' + '1' is the string "A1", not B. The next letter is chr(ord('A') + col).

print ends the line unless you change end.

print(letter) writes the letter and a newline. Pass end="" to stay on the row, then call print() once after the inner loop.

Python Syntax

range stops before its end value, so start + row is the first code that should not print.

Python
start = ord('A')

for row in range(1, rows + 1):
    for code in range(start, start + row):
        print(chr(code), end="")  # same row
    print()                       # end the row

How Python Prints a Letter

Map each part of the console shape to a Python value or call.

PiecePythonWhat it does
Letterprint(chr(code), end="")Writes the character and stays on the row
Code of Aord('A')The number 65
From a columnchr(ord('A') + col)The next letter
str + int'A' + colTypeError
Concat'A' + '1'The string "A1"
Repeat'A' * nn copies of A
New rowprint()Ends the row
Indent" " * nn spaces
Prefixletters[:n]First n characters

Python Examples

Three scripts. Each one changes only the Python that chooses the letter or the leading spaces.

Example 1 — Walk the letter codes with range

Row 1 prints one code. Each later row includes one more, because range stops at start + row.

Python
rows = 5
start = ord('A')

for row in range(1, rows + 1):
    for code in range(start, start + row):
        print(chr(code), end="")
    print()

How It Works

  1. ord('A') is 65. chr turns each later code back into a letter.
  2. end="" keeps those letters on one row.
  3. Bare print() after the inner loop starts the next row.

Example 2 — Build the letter from a column number

Add the column to the code of A, then convert with chr. Four rows stop at D.

Python
rows = 4
start = ord('A')

for row in range(rows):
    for col in range(row + 1):
        print(chr(start + col), end="")
    print()

How It Works

  1. 'A' + col raises TypeError when col is an int.
  2. ord('A') + col stays a number, and chr returns the letter.
  3. Column 0 is A, column 1 is B, and print() ends the row.

Example 3 — Indent with string multiplication

" " * n builds the spaces. The letter loop is unchanged.

Python
rows = 5
start = ord('A')

for row in range(1, rows + 1):
    print(" " * (rows - row), end="")
    for code in range(start, start + row):
        print(chr(code), end="")
    print()

How It Works

  1. " " * (rows - row) is 4 spaces on row 1 and an empty string on row 5.
  2. end="" prints those spaces without starting a new line.
  3. print() still closes the row after the spaces and the letters.

34 Python Alphabet Pattern Programs

Each card is a full Python script: nested for loops, chr and ord, and print(..., end=""). Open one for the walkthrough.

Alphabet Pattern 1
Alphabet Pattern 2
Alphabet Pattern 3
Alphabet Pattern 4
Alphabet Pattern 5
Alphabet Pattern 6
Alphabet Pattern 7
Alphabet Pattern 8
Alphabet Pattern 9
Alphabet Pattern 10
Alphabet Pattern 11
Alphabet Pattern 12
Alphabet Pattern 13
Alphabet Pattern 14
Alphabet Pattern 15
Alphabet Pattern 16
Alphabet Pattern 17
Alphabet Pattern 18
Alphabet Pattern 19
Alphabet Pattern 20
Alphabet Pattern 21
Alphabet Pattern 22
Alphabet Pattern 23
Alphabet Pattern 24
Alphabet Pattern 25
Alphabet Pattern 26
Alphabet Pattern 27
Alphabet Pattern 28
Alphabet Pattern 29
Alphabet Pattern 30
Alphabet Pattern 31
Alphabet Pattern 32
Alphabet Pattern 33
Alphabet Pattern 34

Frequently Asked Questions

Python will not add a str and an int, so 'A' + 1 raises TypeError. 'A' + '1' is the string "A1", not B. The next letter is chr(ord('A') + col).
print(letter) writes the letter and ends the row. print(letter, end="") stays on the same row. A bare print() after the inner loop ends the row. If the default print sits inside the inner loop, each letter lands on its own line.
chr(ord('A') + n) keeps walking through codes, so column 26 is '['. Keep the row count at 26 or less when the shape should stay inside A–Z.
Yes. Store "ABCDE" in letters and print(letters[:row]). The slice returns that prefix, and print adds the newline.

Next: Alphabet Pattern 1

A full Python walkthrough of the right-angled letter triangle, from ord('A') through print().

Alphabet Pattern 1 →

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.

28 people found this page helpful