Discuss / Python / 交作业

交作业

Topic source

frantumaglia

#1 Created at ... [Delete] [Delete and Lock User]
def triangles():    l1 = [1]    while True:        yield l1        l2 = [1,1]        l1 = l2[:1]+[l1[i]+l1[i+1] for i in range(len(l1)-1)]+l2[1:]

附:在一个列表中某个index插入另一个列表的代码

list2 = list2[:index] + list1 + list2[index:] 即在list2 某个index插入list1


  • 1

Reply