Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver2
10いいね 1477回再生

Python's Shallow Copy TRAP! 😱 This Will Change How You Code #PythonGotcha

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

コメント