Post

Python Developer
Python Developer@Python_Dv·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
23
5
61
7.2K
Jenny
Jenny@JennyTheDev·
@Python_Dv B) [1] a = b = [] → both point to the SAME list a.append(1) → modifies that shared list print(b) → [1] The tricky part: "=" doesn't copy, it creates a reference. Welcome to Python's mutable object trap.
English
0
0
3
409
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@Python_Dv Output: B) [1] Explanation: a and b point to the same list. a.append(1) mutates that shared list, so b sees the change too.
English
0
0
2
482
Abdullah Munib
Abdullah Munib@munibcodes·
@Python_Dv B) [1] a and b reference the same list, so appending via a affects b too.
English
0
0
1
177
Earnest Codes
Earnest Codes@Earnesto037·
@Python_Dv (B) [1] When the line a = b = [] is executed in Python, a single empty list object is created in memory, and both variables a and b are made to refer to this exact same object. Lists are mutable objects, meaning their content can be changed after creation without creating a new
English
1
0
1
242
Ehshanulla
Ehshanulla@Ehshanulla·
@Python_Dv a = b = [] → both a and b refer to the same list But oppened is not a valid list method So Python raises an Error
English
0
0
0
26
Paylaş