python 添加list元素

def extend_list(val,list=[]):
list.append(val)
return list

list1 = extend_list(10)
list2 = extend_list(123,[])
list3 = extend_list('a')

print(list1)
print(list2)
print(list3)


默默的想一想答案是什么:




C:\Users\san\AppData\Local\Programs\Python\Python36-32\python.exe E:/love/tongcheng.py
[10, 'a']
[123]
[10, 'a']

进程已结束,退出代码0

 

 

can you explain why ? if you can't ,you should read more 




posted @ 2018-08-13 17:43  五等码农  阅读(2107)  评论(0编辑  收藏  举报