This Python program reads a number from the user and uses nested loops to print the '*' character in a grid-like pattern.
The number of rows determines both the height and width of the output.
This exercise helps reinforce nested loop structures and basic terminal output formatting.
def print_star_grid(rows):
for i in range(rows):
for j in range(rows):
print("*", end="")
print()
# Run the program
rows = int(input("Enter number of rows: "))
print_star_grid(rows)
****
****
****
****
- The outer loop controls the number of rows
- The inner loop prints one asterisk per column in each row
- end="" prevents line breaks inside the row, and print() moves to the next line
- The result is a square grid of asterisks with dimensions equal to the input number