VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
Easy10 XPcopiesbugs

Why did changing a copied list change the original?

What does this print?

a = [[1, 2]]
b = a.copy()
b[0].append(3)
print(a)
Stuck? Show the solution

Answer: B. [[1, 2, 3]]

copy() is shallow: the outer list is new but the inner list is shared. Use copy.deepcopy when nested objects must be independent.

Learn the idea behind itLists and Tuples — Sequences, Copies and What They Cost