简体   繁体   English

如何在python3的列表中追加列表?

[英]How to append list in list in python3?

def cal(i,L,cset,comp):
    for n in range(i,len(L)):
        print(cset+[L[1]])
        comp.insert(cset+[L(n)])
        cal(i+1,L,comp[len(comp)-1],comp)
    return comp
print(cal(0,[1,2,3,4,5],[],[]))

in this code it gives me an error from the first iterration 在这段代码中,第一次迭代给我一个错误

line 4, in cal 第4行,以cal

comp.insert(cset+[L(n)]) comp.insert(CSET + [L(N)])

TypeError: 'list' object is not callable TypeError:“列表”对象不可调用

我确实将comp.insert(cset + [L [n]])更改为comp.insert(cset + [L [n]])只是迷路了:/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM