<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">def f(ilist):
    """ return the sum of a list of elements -- iterative version """
    
    sum = 0
    for elt in ilist:
        sum = sum + elt
        
    return sum

print f([1,2,3])

def frec(ilist):
    """ return the sum of a list of elements -- recursive version """
    
    # base case
    if ilist == []:
        return 0
    
    # the sum of the list is the first element plus the sum of the list after
    # the first element
    return frec(ilist[1:]) + ilist[0]

print frec([1,2,3])</pre></body></html>