list = [4, 7, 11, 15]
I'm trying to create a function to loop through list items, and find the difference between list[1] and list[0], and then list[2] and list[1], and then list[3] and list[2]... and so on for the entirety of the list. I am thinking of using a for loop but there might be a better way. Thanks.
output would be:
list_diff = [3, 4, 4]
def difference(list):
for items in list():
or
def difference(list):
list_diff.append(list[1] - list[0])
list_diff.append(list[2] - list[1])
etc.
...