I want to find the difference between adjacent elements. The first element stays as is. For example:
my_list = [1,2,7,-4,10]
The output would be...
difference_list = [1,1,5,-11,14]
I want to find the difference between adjacent elements. The first element stays as is. For example:
my_list = [1,2,7,-4,10]
The output would be...
difference_list = [1,1,5,-11,14]
Try zipping:
>>> [my_list[0]]+[j-i for i, j in zip(my_list, my_list[1:])]
[1, 1, 5, -11, 14]