mutable tag

1 questions


1 answers
124 views
0
I changed only one element in the list, but the whole element changed. Why is that?

[[1, 1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1]] I wrote it like this. myList = [[1] * 4] * 3I changed only one value at the beginning, but the whole value of the element changed.myList[0][0] = 5 #[5, 1, 1,...


© 2024 OneMinuteCode. All rights reserved.