Discuss / Python / 学习了评论区

学习了评论区

Topic source

YOUTH

#1 Created at ... [Delete] [Delete and Lock User]

def triangles():

    l=[1]

    while True:

        yield l

        #起始位补[0]

        a = [0] + l

        #注意选好range范围,这里选到len(a)-1,即从0到len(a)-2,不含len(a)-1,最后末尾补[1]

        l = [a[i] + a[i + 1] for i in range(0, len(a) - 1)]+[1]


  • 1

Reply