Python function to find the average of given numbers


Topic: Python function to find the average of given numbers

Solution

def average():
    numbers = []
    def add(number):
        numbers.append(number)
        total = sum(numbers)
        count = len(numbers)
        return total/count
    return add
a = average()
a(10)
a(20)
a(45)



List all Python Programs