I want to find difference between elements of list2 only and only if they are present between elements of list1. Ignore any other case and move to next iteration. I am trying to do this operation in python 3.9
eg: Case 1: 1.2 & 1.6 from list2 are present between 1 & 2 from list1, so difference is saved in new list3 as [0.4]. moving on expected appended list should be [0.4,0.5,0.5] and so on.
Case 2: Between 4 & 5 of list1, there are 3 elements present in list2 i.e - 4.1, 4.5 and 4.9. so ignore this and move to next set of elements of list1.
Case 3: Between 5 & 6 of list1, there is only 1 elements [resent in list2 i.e - 5.5, so ignore this as well since two elements are needed for calculating difference. Hence move to next set of elements in list1.
Case 4: Between 6 & 7 of list1, there are two elements present in list2 i.e 6.2 and 6.3, so append the list3 as - [0.4,0.5,0.5,0.1] and move to next set in list1.
I hope I was able to explain the problem and apologies since it is my first question on StackOverflow community.
list1 = [1,2,3,4,5,6,7]
list2 = [1.2,1.6,2.3,2.8,3.1,3.6,4.1,4.5,4.9,5.5,6.2,6.3]
Expected output -
[0.4,0.5,0.5,0.1]