This Python program uses nested loops to print a grid of '*' characters in the terminal.
The number of rows and columns is determined by user input, allowing for flexible pattern size.
This exercise helps practice nested loop structures and character-based output formatting.
def print_star_grid(rows, cols):
for i in range(rows):
for j in range(cols):
print("*", end=" ")
print()
# Run the program
rows = int(input("Enter number of rows: "))
cols = int(input("Enter number of columns: "))
print_star_grid(rows, cols)
* * * * *
* * * * *
* * * * *
- The program first reads the number of rows and columns from the user
- The outer loop controls the number of lines (rows)
- The inner loop prints '*' characters across each line (columns)
- Each line ends with a newline to form a rectangular grid of asterisks