Append Sum question: why I can't use [-n:] to append item to list

hey guys, I’m doing this optional challenge for python 3, I do not quite understand the second challenge: append sum,

here is my solution,

def append_sum(lst):
  return lst

but I get result
[1, 1, 2, [1, 2], [2, [1, 2]], [[1, 2], [2, [1, 2]]]]

the correct answer use:

I don’t understand why my solution doesn’t work, and what it the difference?

thank you in advance.

Welcome back to the forums!

This challenge is asking you to append the sum of the last two elements in the list, essentially creating a Fibonacci sequence. Your code however instead appends the last two elements of the list to lst each time, as a list slice.

1 Like

thank you, now I realize why I did wrong

1 Like