Write a function that takes in a list of numbers and outputs the mean of the numbers using the formula for mean. Do this without any built-in functions like sum(), len(), mean()

the sum of the numbers divided by how many numbers


In [125]:
def mean_numbers(list): #pasamos un list siempre
    #print('entro al loop')
    #print(type(list)) #comprobamos que es un list
    #print(list)
    list_to_sum = 0 #creo una nueva lista vacia para poder sumar
    number_of_elements_in_list= 0
    for item in list: #hago un loop de mi lista original y le voy diciendo que me sume cada elemento
        list_to_sum += item
        number_of_elements_in_list= number_of_elements_in_list +1
    return list_to_sum/ number_of_elements_in_list

In [126]:
mean_numbers([2,3,4,5,6])


Out[126]:
4.0

In [ ]: