for in num_listthe_sum the_sum return the_sum print(list_sum([ , , , , ])pretend for minute that you do not have while loops or for loops how would you compute the sum of list of numbersif you were mathematician you might start by recalling that addition is function that is defined for two parametersa pair of numbers to redefine the problem from adding list to adding pairs of numberswe could rewrite the list as fully parenthesized expression such an expression looks like this(((( we can also parenthesize the expression the other way around( ( ( ( )))notice that the innermost set of parentheses( )is problem that we can solve without loop or any special constructs in factwe can use the following sequence of simplifications to compute final sum total ( ( ( ( )))total ( ( ( ))total ( ( )total ( total how can we take this idea and turn it into python programfirstlet' restate the sum problem in terms of python lists we might say the the sum of the list num_list is the sum of the first element of the list (num_list[ ])and the sum of the numbers in the rest of the list (num_list[ :]to state it in functional formlist_sum(num_listfirst(num_listlist_sum(rest(num_list)in this equation first(num_listreturns the first element of the list and rest(num_listreturns list of everything but the first element this is easily expressed in python as the followingdef list_sum(num_list)if len(num_list= return num_list[ elsereturn num_list[ list_sum(num_list[ :]print(list_sum([ , , , , ])there are few key ideas in this to look at firston line we are checking to see if the list is one element long this check is crucial and is our escape clause from the function the sum of list of length is trivialit is just the number in the list secondon line our function calls recursion