Discuss / Python / 实现了目标,但是代码不够简洁

实现了目标,但是代码不够简洁

Topic source

叫小小兽

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

def triangles(): line,last = 1,[1] while True: line_list = [] for x in range(line): n = x + 1 if n == 1 or n == line: line_list.append(1) else: line_list.append(last[x] + last[x-1]) yield line_list last = line_list line = line + 1


  • 1

Reply