In Python, why does concatenating a list to another one creates another object in memory, whereas other manipulations induce mutation of the original object in memory?
*CASE A : list=[0, 1, 2, 3] list_copy=list list=list+[4] print(“list is ”,list) print(“list_copy is “, list_copy) ————— Print output : list is [0, 1, 2, 3, 4] list_copy is [0, 1, 2, 3] ————— (this non-mutating behavior also happens when concatenati...
Jul 19, 2017DS