Post

@Python_Dv Output: B — [[5], [5]]
Explanation (short):
[[0]] * 2 creates two references to the same inner list.
Updating x[0][0] = 5 changes it for both.
Result → [[5], [5]]
English

@Python_Dv Answer: B
The code initializes a list x by repeating the list [0] twice using the * operator. In Python, when a mutable object (like a list) is duplicated this way, both instances within the outer list refer to the same underlying object in memory.
English

@Python_Dv Answer: B[[5], [5]]
The code x = [[0]] * 2 creates a list containing two references to the same inner list [0]. This is because multiplying a list with nested objects creates multiple shallow copies, not deep copies.Therefore, x is initialized as [[0], [0]], but
English

@Python_Dv The answer is B. Shallow copies strike again! 😅 This is exactly why you use list comprehensions like [[0] for _ in range(2)] instead.
English

@Python_Dv Output : B [[5][5]] ✅
x = [[0]] * 2 --> [[0] [0]] # two references to the SAME inner list
x[0][0] = 5 --> [[5][5]] # modifies that single inner list
print(x) --> [[5][5]] ✅
English

@Python_Dv D, error. The second line has a ) with no matching (.
English










