Discuss / Python / 交作业,亲测可行

交作业,亲测可行

Topic source

shoppingxi

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

    t1,x=1,[1]

    while t1<=10:

        y=[x[0] if t2==0 or t2==t1-1  else x[t2-1]+x[t2] for t2 in range(0,t1) ]

        x=y

        yield y            

        t1=t1+1

shoppingxi

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

   简化了一下

    x=[1]

    while True:

        yield x

        x=[1 if t==0 or t==len(x)  else x[t-1]+x[t] for t in range(0,len(x)+1) ]


  • 1

Reply