# 杨辉三角 def triangle(): li = [1] while True: yield li lis = [] lis.extend([li[0]]) for j in range(len(li)-1): lis.append((li[j]+li[j+1])) else: lis.extend([li[0]]) li = lis tri_list = triangle() for i in range(10): print(next(tri_list))
原文地址:https://www.cnblogs.com/ibester/p/11619298.html
时间: 2024-10-14 08:55:35