Im working through the Python 3 course and I’m up to this section:-
It is asking to define a function ‘append_sum(lst)’ and append the last two elements of lst together and append the result to lst. This process is to be repeated 3 times.
I have already looked at the solution and it makes no sense to me having got this far in the list section.
My main confusion arises from the fact I dont know how many items are in lst as its not a defined list of numbers. It is simply ‘lst’. How do i know what are the last two elements? Have i missed something from previous lessons as I cant remember this been covered.
Does ‘lst’ automatically generate a list? I always thought you had to define a list of numbers or strings i.e:
mylist = list[1, 2, 3, 4, 5]