Nested lists are DANGEROUS! Can you predict the output? 👇
Options:
A) [[99, 2], [1, 2]] ❌
B) [[99, 2], [99, 2]] ✅ (Mind-blown!)
C) [[1, 2], [1, 2]] ❌
D) Error ❌
💡 The Shocking Truth:
a.copy() only does a SHALLOW copy
The nested list still references the original 'a'
Both elements in 'b' point to the SAME inner list!
#PythonLists #ShallowCopy #ProgrammingMistakes #CodeDebugging #PythonTricks
Drop a 🤯 if this surprised you!
Follow for more Python tra
コメント