My output is correct but when I press "check answer" it gives a different result

This is from the list coding challenge Number 1, “Append Sum.”

The challenge is to, " Write a function named append_sum that has one parameter — a list named named lst .

The function should add the last two elements of lst together and append the result to lst . It should do this process three times and then return lst .

For example, if lst started as [1, 1, 2] , the final result should be [1, 1, 2, 3, 5, 8] ."

This is the code I wrote:

#Write your function here
def append_sum(lst):
  while len(lst) < 6:
    lst.append(lst[-2] + lst[-1])
  return lst

#Uncomment the line below when your function is done
print(append_sum([1, 1, 2]))

When I press run, the code outputs the correct result ([1, 1, 2, 3, 5, 8]) but when I press “check answer” it responds with " append_sum([2, 5]) should have returned [2, 5, 7, 12, 19] , and it returned [2, 5, 7, 12, 19, 31]"

Hello, @method2161221558, and welcome to the forums.

The SCT for the challenge tests your code using the list shown in the message you are receiving:
[2, 5].
Your function should work for lists of any length. Yours only produces the expected outcome if the original list has exactly 3 elements. The instructions say to repeat something three times. Your function wouldn’t append even a single element if the original list had 6 or more elements.