This Python program reads an integer from the user and uses a for loop to print the character 'x' in each line.
The number of lines is determined by the input value.
This exercise helps reinforce basic loop structures and terminal output formatting in Python.
def print_x_lines(n):
for i in range(n):
print("x")
# Run the program
rows = int(input("Enter number of lines: "))
print_x_lines(rows)
x
x
x
x
x
- The program first reads an integer from the user
- A for loop runs for the specified number of iterations
- In each iteration, the character 'x' is printed on a new line