Part of the series

Several example codes

~1 min read • Updated Oct 11, 2025

Program Overview

This Python program reads an integer from the user, representing the number of lines.
In each line, it prints the '*' character exactly 17 times using a nested loop.
This exercise helps reinforce loop structures and fixed-length pattern printing in Python.


Python Code:


def print_seventeen_stars_per_line(lines):
    for i in range(lines):
        for j in range(17):
            print("*", end="")
        print()

# Run the program
lines = int(input("Enter number of lines: "))
print_seventeen_stars_per_line(lines)

Sample Output (input: 2):


*****************
*****************

Step-by-Step Explanation:

- The program first reads the number of lines from the user
- The outer loop runs once for each line
- The inner loop prints 17 asterisks per line
- The result is a block of lines, each containing exactly 17 '*' characters


Written & researched by Dr. Shahin Siami