Discuss / Python / 作业, 不如前面一个哥们儿写得好

作业, 不如前面一个哥们儿写得好

Topic source

def triangles():

L = [1]

while True:

yield L

# 首尾插入0,方便计算

L1 = [x for x in L]

L1.insert(len(L), 0)

L1.insert(0,0)

L = [value + L1[index - 1] for index, value in enumerate(L1) if index > 0]


  • 1

Reply