Discuss / Python / 好像可以hhh

好像可以hhh

Topic source

-- coding: utf-8 --

author = 'FTY'

#输出杨辉三角前x项

def triangles(x): L= [1,1] n = 1 x==1 yield [1] while n<x: yield L L = [L[i] + L[i+1] for i in range(n)] L.insert(0, 1) L.append(1) n = n + 1 return 'done' r = triangles(x)#输入x for i in r: print(i)


  • 1

Reply