Dec-25-2020, 08:51 PM
Hello,
I am having an issue with subtracting sublists. With the given sublist:
first_list: [[0, 1], [2,4], [8,7]]
There is supposed to be a new list where that contains the difference of the first element from the second element in the sublist:
[-1,-2,-1]
This is the code so far:
for sub_list in data:
differences.append((int(sub_list[1]))-(int(sub_list[0])) in data)
I tried to run this with the other part of the problem to multiply the resulting list, but it fails. It seems to be not iterating. Can anyone offer some suggestions?
I am having an issue with subtracting sublists. With the given sublist:
first_list: [[0, 1], [2,4], [8,7]]
There is supposed to be a new list where that contains the difference of the first element from the second element in the sublist:
[-1,-2,-1]
This is the code so far:
for sub_list in data:
differences.append((int(sub_list[1]))-(int(sub_list[0])) in data)
I tried to run this with the other part of the problem to multiply the resulting list, but it fails. It seems to be not iterating. Can anyone offer some suggestions?