更新时间:2023-11-28 23:21:28
您必须返回并将返回的值分配给list1
:
You have to return and assign the returned value to list1
:
def func(list1):
list1 = list1[2:]
print(list1) # prints [2, 3]
return list1
list1=func(list1)
,否则您必须在func()
内将list1
引用为global
.
or you have to reference list1
as global
inside func()
.