0

I've been trying to create a program that creates an n x n triangle starting with a number s and works its way downward for each column, but instead of creating a triangular pattern, it just fills the whole matrix with the value of the last counted number. I've tried printing my i and j values, but they're moving alright. Is there anything I've missed?

n, s = map(int, input().split())
a = [[" "]*n]*n

for j in range(n):
    for i in range(j+1):
        a[i][j] = s
        s += 1
        if s == 10:
            s = 1

for i in range(n):
    for j in range(n):
        print(a[i][j], end = " ")
    print()
Nimantha
  • 5,793
  • 5
  • 23
  • 56
xq40
  • 1

0 Answers0