Aug-12-2022, 04:10 PM
Hello everyone,
I would like to calculate the sum of the differences between each value for each tuple. For instance :
(4,7,9) would give 3 (7-4 = 3) and 2 (9-2). And the sum of these differences would be 5.
And after that, I would like to print only the tuples whith a sum superior to a value.
So, for instance, if I put that list of tuples :
I have no idea how I can calculate the difference between each value of each tuple. Anyone could help me please ?
I would like to calculate the sum of the differences between each value for each tuple. For instance :
(4,7,9) would give 3 (7-4 = 3) and 2 (9-2). And the sum of these differences would be 5.
And after that, I would like to print only the tuples whith a sum superior to a value.
So, for instance, if I put that list of tuples :
[(4,8,10,13); (8,11,14,15), (9;16;18;19)]And then, I put a condition to print only the tuples with a sum of differences inferior to 10, then it will return this result :
[(4,8,10,13); (8,11,14,15)]About the code, I am a little bit lost.
I have no idea how I can calculate the difference between each value of each tuple. Anyone could help me please ?