Discuss / Python / 请问

请问

Topic source

def sanjiao(max): L=[1] while len(L)<=max: yield L L=[1]+[L[x]+L[x+1] for x in range(len(L)-1)]+[1] 这里第三行生成list时len(L)=2带入为什么L[0]+L[x+1]会等于2呢

f伪善

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

你不是都知道x= 0 了吗 L[x+1]不就是L[1]吗 L[0]=L[1]=1啊


  • 1

Reply