I have some pretty simple function that tries to return a list that is the distance between the inputted list and the average of that list. The code almost works. Any thoughts as to why the results are slightly off?
def distances_from_average(test_list):
average = [sum(test_list)/float(len(test_list))]*len(test_list)
return [x-y for x,y in zip(test_list, average)]
Here are my example results: [-4.200000000000003, 35.8, 2.799999999999997, -23.200000000000003, -11.200000000000003] should equal [4.2, -35.8, -2.8, 23.2, 11.2]