Logic Building
# Take n
n = int(input("Enter number of rows: "))
# Print Floyd triangle
num = 1
for i in range(1, n + 1):
for j in range(1, i + 1):
print(num, end=" ")
num += 1
print()Output
Enter number of rows: 4 1 2 3 4 5 6 7 8 9 10
Print consecutive numbers in rows.
Key Concepts:
- Use counter variable
- Increment after each print
- Different numbers per row