0

Dears,

Could anyone explain to me why the values of cells in row1 to row8 are also changed to 1? My intention is to change the value of cells in the row0.

w = 8
W = [1,3,4]

def max_gold(W,w):
    L = [0]*(len(W)+1)
    M = [0]*(w+1)
    for i in range(len(M)):
        M[i] = L
    for r in range(len(M)):
        for c in range(len(W)+1):
            # W_n = r
            if r == 0:
                M[r][c]= 1
    return M
                        
M = max_gold(W,w)  
for i in range(len(M)):
    print(i,M[i])
hola_mundo
  • 21
  • 5

0 Answers0