0

i tried to copy an array into another array multiple times in python like this

l = [3,4,2]

d = []

x = [[3,1],[4,8],[8,2]]   

for place in range(len(l)):

    d.extend([x[place]] * l[place]) 

print(d)

(d[3])[1] = (d[3])[1] - 1

print(d)

but the problem is that all the items in the array from the same type become linked i cant use somthing like

[[3,1] for _ in range(3)]

because with a lot of items in x it will take a lot of useless code is there a way to fix this?

baz
  • 1
  • 1

0 Answers0