Views vs Copies
Slicing = view (shared memory). Use .copy() for independence:
c = a[1:4].copy() c[0] = 999 # a unchanged
Why this matters
This lesson prevents silent bugs: mutating a slice and accidentally corrupting the original array is one of the most common NumPy footguns.
The same idea shows up in pandas .loc and chained-assignment gotchas.
ResourcesDocs, references & more — opens in a new tab
🎯 Your Task
original = [10,20,30,40,50]. Copy [1:4] → safe_slice. Set [0]=999. Verify original unchanged.
safe_slice = original[1:4].copy()
⌘⏎ run · ⌘← → nav
▶ Output
Run your code to see output here.