0

What's the difference between this two types of list of lists what do you use the first one for?

lst1 = [[0, 0]] * 3
lst2 = [[0, 0], [0, 0], [0, 0]]
lst1[0][0] = 1
lst2[0][0] = 1
print("lst1 = ", lst1)
print("lst2 = ", lst2)

outputs:

lst1 = [[1, 0], [1, 0], [1, 0]]

lst2 = [[1, 0], [0, 0], [0, 0]]

Ben Katzav
  • 80
  • 6

0 Answers0