Last active
July 6, 2019 16:39
-
-
Save eyaltrabelsi/c9a14aaae6cb54fa24ec530b5beed818 to your computer and use it in GitHub Desktop.
Python trick list comprehension with previous value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a = [1, 2, 4,2] | |
>>> [y - x for x,y in zip(a,a[1:])] | |
[1, 2, -2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment