I have worked my way through the topic Lists in Python, but have had to stop during the first code challenge. The challenge reads as follows:
Write a function named
append_sumthat has one parameter — a list named named
lst.The function should add the last two elements of
lsttogether and append the result to
lst. It should do this process three times and then return
For example, if
[1, 1, 2], the final result should be
[1, 1, 2, 3, 5, 8].
I believe one of the key concepts is to break down the actual task, so I have started to create this function only aiming to add one element to the list.:
sum_elements = (lst[-2] + lst[-1])
However, the function evaluates to
None, once an input is given. I guess, my question is, why is that ?
I was under the impression, that it should work like this:
lst = [1, 2, 3]
[1, 2, 3, 4]
It is my first question posted. Please let me know, if I did not follow any community guidelines.