def my_append1(list1, item):
list1 = list1 + [item]
return
def my_append2(list1, item):
list1 += [item]
return
以上两个函数给出了不同的结果:
test = [1, 2, 3]
my_append1(test, 1)
print(test) ==> [1, 2, 3]
test = [1, 2, 3]
my_append2(test, 1)
print(test) ==> [1, 2, 3, 1]
为什么他们不同?