Number Pattern 2

Print number pattern: 1, 22, 333, ...

Logic BuildingIntermediate
Logic Building
# Take n
n = int(input("Enter number of rows: "))

# Print pattern
for i in range(1, n + 1):
    for j in range(1, i + 1):
        print(i, end="")
    print()

Output

Enter number of rows: 4
1
22
333
4444

Print row number i times.

Key Concepts:

  • Outer loop: rows
  • Inner loop: print i, i times
  • Same number repeated