Discuss / Python / 我也来交作业,是在原列表里修改

我也来交作业,是在原列表里修改

Topic source

GUK0

#1 Created at ... [Delete] [Delete and Lock User]
def triangles():
    a = [1]
    while True:
        yield(a)
        i = 1
        last = a[0]
        a.append(0)
        while i<len(a):
            t = a[i]
            a[i] += last
            last = t
            i += 1

阿川ks

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

def yor(max): i,n,L,L1,L2 = 0,0,[1],[1],[1,1] if max == 1: yield L1 elif max ==2: yield L2 else: yield L1 yield L2 n = n + 2 L0 = L2 while n < (max-1): for x in range((len(L0)-1)): L.append(L0[i]+L0[i+1]) i =i+1 L.append(1) yield L L0 = L L = [1] n = n+1 i = 0 return 'ok'


  • 1

Reply