.append list using loop

I’m having a bit of an issue a loop
With my code

def append_sum (lst): fouc = len(lst) for i in range(fouc): while i <= 2: i = lst[-1] + lst[-2] lst.append(i) print(lst) print(append_sum([1, 1, 2]))

I can control the number of steps changing the value of “I” however, I always end up with the “none” line at the end. Why does this happen, and how should I fix it?

Your function has no return statement, as such there is nothing for line 16 to print.

3 Likes