Texas Water Development BoardRole: Python Web ProgrammerSeptember 2026
Interview question
Why does changing one element change all the inner lists in this Python example?
l = [[0]] * 10
print(l)
# [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0]]
l[0][0] = 1
print(l)
# [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]