Post

Python Developer
Python Developer@Python_Dv·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
18
10
71
7K
Sergei Kotov
Sergei Kotov@kotov_dev·
Answer: B) [1, 2, 3, 4] The key: b = a creates a reference + lists are MUTABLE! › b and a point to SAME list › b += [4] works like b.extend([4]) › Modifies in-place, not creates new list › Shared list becomes [1,2,3,4] › a sees the change! For beginners: += with lists behaves like .extend() - modifies in-place!
English
1
0
7
613
Earnest Codes
Earnest Codes@Earnesto037·
@Python_Dv Understanding this distinction between assignment (creating a new reference) and copying (creating a new, independent object) is crucial for predicting how mutable data structures like lists behave in Python. B). [1, 2, 3, 4] is the correct answer to the Python code challenge.
English
1
0
4
424
Jenny
Jenny@JennyTheDev·
@Python_Dv B. [1, 2, 3, 4] b = a doesn't copy the list. It copies the reference. When you modify b, you're modifying a too. This is why shallow vs deep copy matters.
English
0
0
3
292
Ehshanulla
Ehshanulla@Ehshanulla·
@Python_Dv b = a → both variables refer to the same list b += [4] modifies the list in place (it’s like append, not reassignment) output= [1, 2, 3, 4]
English
0
0
1
97
Paylaş