Discuss / Python / 自己写的笨方法

自己写的笨方法

Topic source

    L=[1]

    while True:

        try:

            yield L

            L=[L[i]+L[i+1] for i in range(len(L)-1)]

            L=[1]+L[:]+[1]

        except StopIteration as e:

            print('Generator return value:', e.value)

            break


  • 1

Reply