Most of learners used a nested range-for.
But I think, there should be something easier to make it, since it's usual to add up members in two list, like:
[22,33,44] + [1,1,1,] and get [23,34,45]
I've thought one like this:
r = [1] + [x+y for x,y in f,b ]
But it's not right.
# -*-coding: utf-8 -*-
def tri():
f = [1,]
yield(f)
while(True):
b = f[1:(len(f))] + [0,]
r = [1] + [x+y for x,y in f,b ] //!
f = r
yield(f)
n = 0
for t in tri():
print(t)
n = n + 1
if n == 4:
break
施小蛋_49563
Most of learners used a nested range-for. But I think, there should be something easier to make it, since it's usual to add up members in two list, like:
[22,33,44] + [1,1,1,]
and get[23,34,45]
I've thought one like this:r = [1] + [x+y for x,y in f,b ]
But it's not right.