Created
October 11, 2015 20:45
-
-
Save rknLA/8b0bae3c28c49e819761 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
distances = [] | |
i = 0 | |
while i < len(sorted_forces) — 2: | |
this_val = sorted_forces[i] | |
next_val = sorted_forces[i+1] | |
# ^^ this is why we use -2 instead of -1 in the while condition | |
distance = next_val — this_val | |
distances.append(distance) | |
i += 1 |
Thanks! I always forget about zip
!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could write this much more succinctly using a list comprehension: