def parse_directions_response(directions_response):
  """Extract basic information relevant to route from the response.

  Args:
    directions_response: list of directions in the deserialized
    Maps API response format
  Returns:
    if a valid route is found a tuple containing:
      a list of the (lat,lon) points on the route
      a list of distances between those points (in meters)
    otherwise: raises a Value Error since no routes were produced
  """
  if directions_response:
    route_response = directions_response[0]
    route_points = []
    route_distances = []

    legs = route_response["legs"]
    first_point = (legs[0]["steps"][0]["start_location"]["lat"],
                   legs[0]["steps"][0]["start_location"]["lng"])
    route_points.append(first_point)

    for leg in legs:
      for step in leg["steps"]:
        new_point = (step["end_location"]["lat"],
                     step["end_location"]["lng"])
        new_distance = step["distance"]["value"]  # distance from step's start to end in meters
        route_points.append(new_point)
        route_distances.append(new_distance)

    return (route_points, route_distances)

  else:
    raise ValueError("no route between start and end, try new points")