Discuss / Python / 应该还有更好的方法吧

应该还有更好的方法吧

Topic source

o保温杯o

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

def triangles(): n, l = 1, [] while n >0: if n == 1: l = [1] else: l = [l[a + 1] + k for a, k in enumerate(l) if a < len(l) - 1] l.append(1) l.insert(0, 1) yield l n = n + 1

#根据前面的知识,我就想到这么傻瓜的方法


  • 1

Reply