Not sure what you trying to do but if you need a list of numbers with some starting point, you can simply generate them using list comprehension as:
a = 2
x = [i+a for i in range(1, 50)]
print(x)
EDIT: Based on comments from author.
You need to change print
to return
the generated number. Also, need to add a loop
and a list
to generate a new number and keep appending
the new number to the list
.
Note: As said earlier, it is recommended to use Python's supported features like list comprehension as is shown in the original code.
a = 1
def test(i):
p = a + i
return p
res = []
for i in range(2, 50):
res.append(test(i))
print(res)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…