Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

list average python recursion

def average(a):  
    if len(a) == 1:  
        return a[0]  
    else:  
        n = len(a)
        return (a[0] + (n - 1) * average(a[1:])) / n  

print(average([1,2,3]))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #list #average #python #recursion
ADD COMMENT
Topic
Name
2+6 =