标签: python-3.x
from itertools import product a=[[1],[1,2],[1,2,3]] r=len(a) c=r-1 for k, l in product(range(c),range(c-k,0,-1)): a[k]=a[k]+[0] print(a)
我收到错误“NameError:名称'k'未定义”
预期产出:
[[1,0,0],[1,2,0],[1,2,3]]