diff --git a/nav.py b/nav.py index 44d15f6..4fe895e 100644 --- a/nav.py +++ b/nav.py @@ -79,8 +79,9 @@ def distance(a, b): def legs(route): - """Return the legs (pairs of consecutive waypoints) of a route.""" - return [(route[i], route[i + 1]) for i in range(len(route) - 1)] + """Yield the legs (pairs of consecutive waypoints) of a route.""" + for i in range(1, len(route) - 1): + yield route[i], route[i + 1] def plan(destination):