r/PythonProjects2 • • May 10 '26

Why print this

Post image

I don't understand

8 Upvotes

7 comments sorted by

View all comments

1

u/butterfly_orange00 May 10 '26 edited May 10 '26
#  n = g

for i in range(len(n)) : # len(g) = 4
# let's assume that i = 0
    x = g[i]  # that will return the first raw, x = [1,0,1,0]
    
    g[x] [i] # it's like g[1,0,1,0][0], and that's will return 1

# so to use your code you should write:

for i in range(len(n)) :
    n[i][i] = n[i-1][i-1] 
# n[0][0] = n[0-1][0-1]