How can I find all differences of two consecutive values from a list? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I find all differences of two consecutive values from a list?

''' I have a list of thousands value, it looks like that: c = [9.00205, 9.00394, 9.00582, ...] ''' #My empty attempt: if i in c while i<len(c): (i)-(i+1) It would be good if it is lambda function. THANKS!

23rd Apr 2020, 9:16 AM
Andrey Shintar
Andrey Shintar - avatar
1 Answer
0
It's completed. The answer is all_diff = [j-i for i, j in zip(c[:-1], c[1:])]
23rd Apr 2020, 9:38 AM
Andrey Shintar
Andrey Shintar - avatar