def _list_distance(list1, list2, metric):
    """
    Calculate distance between two lists of the same length
    according to a given metric.

    Assumes that lists are of the same length.

    Args:
        list1 (list): first input list.
        list2 (list): second input list.
        metric (str): 'identity' counts identical positions,
                       'euclid' calculates the Euclidean distance (L2 norm),
                       'taxi' calculates the taxicab (Manhattan) distance
                           (L1 norm),
                       'sup' returns maximum distance between positions,
                       'inf' returns minimum distance between positions.

    Returns distance between the two lists.

    Raises:
        ValueError if unsupported distance metric used.
    """
    # Equal length of both lists is assumed
    distance = 0
    if metric == 'taxi':
        distance = sum([abs(list1[pos] - list2[pos])
                        for pos in range(len(list1))])
        return distance
    elif metric == 'euclid':
        distance = sum([(list1[pos] - list2[pos]) ** 2
                        for pos in range(len(list1))])
        return distance ** 0.5
    elif metric == 'identity':
        distance = sum([list1[pos] != list2[pos]
                        for pos in range(len(list1))])
        return distance
    elif metric == 'sup':
        distance = max([abs(list1[pos] - list2[pos])
                        for pos in range(len(list1))])
        return distance
    elif metric == 'inf':
        distance = min([abs(list1[pos] - list2[pos])
                        for pos in range(len(list1))])
        return distance
    else:
        raise ValueError("Proper distance calculation metrics are \'taxi\',\
                          \'euclid\', \'identity\', \'sup\', or \'inf\'.")