Compulsory Task 1 Follow these steps: ● In a file called sum_recursion, create: o a function that takes a list of integers and an integer as 2 arguments. The integer will represent an index point. o This function needs to add the sum of all the numbers in the list up until and including the given index point by making use of recursion and no loops. Examples of input and output: adding_up_to([1, 4, 5, 3, 12, 16], 4) => 25 What I have tried: <pre>def sumoflist(list): if len(list) == 1: return list[0] else: return list[0] + sumoflist(list[1:]) list = [5,2,3,1] sum = sumoflist(list) print(sum)
def sumoflist(list, index):
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)