note that your expected output is incorrect and not consistent with your attempt at code
elements with index 0 and 1 are calculated as 0-1 and 2-4, while element with index 2 is calculated as 7-8
in your attempt you do int(sub_list[1])-int(sub_list[0]), so basically if that's correct the output is
elements with index 0 and 1 are calculated as 0-1 and 2-4, while element with index 2 is calculated as 7-8
in your attempt you do int(sub_list[1])-int(sub_list[0]), so basically if that's correct the output is
[1, 2, -1]
>>> spam = [[0, 1], [2,4], [8,7]] >>> [n2-n1 for n1, n2 in spam] [1, 2, -1]
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs