Jul-06-2020, 10:28 AM
Hi All,
In the below example, why the result is different?
what the different between "n += [4, 5]" AND "n = n + [4, 5]"?
In the below example, why the result is different?
what the different between "n += [4, 5]" AND "n = n + [4, 5]"?
list1 = [1, 2, 3]
list2 = [1, 2, 3]
def proc1(n):
n += [4, 5]
def proc2(n):
n = n + [4, 5]
proc1(list1)
print list1 #>>>> [1, 2, 3, 4, 5]
proc2(list2)
print list2 #>>>> [1, 2, 3] !!!
