Files
2024-12-07 22:22:21 +02:00

16 lines
471 B
Python

# Q10
# Receive input from the user
n = int(input("Enter a natural number (n): "))
# Variable to store the current number
current_number = 1
# Outer loop to print according to the number of rows
for row in range(1, n + 1):
# Inner loop to print the numbers for the current row
for col in range(row):
print(current_number, end=" ")
current_number += 1 # Increment the number
print() # Move to the next line after finishing the current row