repl.it
@zed1/

Use zip to combine lists pairwise

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
xs = [1, 2, 3, 4, 5, 6]
ys = [2, 3, 4, 5, 6, 7]
points = list(zip(xs, ys))
distances = [((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
             for (x1, y1), (x2, y2) in zip(points, points[1:])]
print(*distances)