Skip to content

Instantly share code, notes, and snippets.

@eyaltrabelsi
Last active July 6, 2019 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyaltrabelsi/c9a14aaae6cb54fa24ec530b5beed818 to your computer and use it in GitHub Desktop.
Save eyaltrabelsi/c9a14aaae6cb54fa24ec530b5beed818 to your computer and use it in GitHub Desktop.
Python trick list comprehension with previous value
>>> 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