0
def perform_magic(first, second):
       third = first[0]
       first[0][0] = 5

       second.append(third)
       second[1][1] = 8
       second.append([6,7])

first = [[3,4]]
second = [[1,2]]

perform_magic(first, second)

print(first[0])
print(second[2])

Output: [5,8] [6,7]

When i executed 'second[1][1] = 8' this also changed the value in first[0][1] from 4 to 8. Why?

0 Answers0