What it does
Calculates the mean difference for a list of any combination of ints (I think).
What I want to know
The only other way I can think of doing this is using recursion.
I’d like to know if there are other ways to do this.
nums = (3, 1, 2, 5, 1, 5, -7, 9, -8, -3, 3) l = len(nums) - 1 diff_list = () for i in range(l): diff = nums(0) - nums(1) if diff < 0: diff = nums(1) - nums(0) print(diff) diff_list.append(diff) nums.pop(0) mean = sum(diff_list)/len(diff_list) print(round(mean, 1))