Discuss / Python / 杨辉三角_提问

杨辉三角_提问

Topic source

状元刚01

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-

def triangles():  
  L=[1] 
  while True:
    yield L
    L=[1]+[L[n]+L[n+1] for n in range(len(L)-1)]+[1]

请问这里当L=[1]时,len(L)=1,range(len(L)-1)就是range(0),这是什么情况?相是出现空集,所以L[n]+L[n+1]也为空集?


  • 1

Reply