python_列表

def f(x,l=[]):
    for i in range(x):
        l.append(i*i)
    print(l)

f(2)
f(3,[3,2,1])
f(3)
结果:
[0, 1]
[3, 2, 1, 0, 1, 4]
[0, 1, 0, 1, 4]


def f(x,l=[]):
    for i in range(x):
        l.append(i*i)
    print(l)

f(2)
#f(3,[3,2,1])
f(3)

结果:
[0, 1]
[0, 1, 0, 1, 4]

 

def f(x,l=[]):
    for i in range(x):
        l.append(i*i)
    print(l)

#f(2)
#f(3,[3,2,1])
f(3)

结果:
[0, 1, 4]

  

posted @ 2021-09-13 20:23  七彩木兰  阅读(29)  评论(0编辑  收藏  举报