Part of the series

Several example codes

~2 min read • Updated Oct 1, 2025

Program Overview

This Python program uses nested loops to generate two types of output:
1. A simple vertical list of numbers
2. A structured 8×8 table where each row starts with an increasing number and continues sequentially


Python Code:


# Part 1: Simple vertical output
for i in range(1, 3):
    print(i)

print()  # Empty line between outputs

# Part 2: Structured table output
for row in range(1, 9):
    for col in range(8):
        print(row + col, end=" ")
    print()

Sample Output:


1  
2  

1 2 3 4 5 6 7 8  
2 3 4 5 6 7 8 9  
3 4 5 6 7 8 9 10  
4 5 6 7 8 9 10 11  
5 6 7 8 9 10 11 12  
6 7 8 9 10 11 12 13  
7 8 9 10 11 12 13 14  
8 9 10 11 12 13 14 15

Step-by-Step Explanation:

- The first loop prints numbers 1 and 2 vertically
- A blank line separates the two outputs
- The second loop uses nested structure:
— Outer loop controls rows (1 to 8)
— Inner loop adds column index to row index to generate each cell
- end=" " keeps numbers on the same line
- print()


Written & researched by Dr. Shahin Siami