def worst_range(A, target):
    """
    Given a sorted list, find the range A[lo:hi] such that all values in the range
    equal to target.
    """
    if not target in A:
        return None
    lo = A.index(target)
    if lo == len(A)-1:
        return (lo, lo)

    hi = lo + 1
    while hi < len(A):
        if A[hi] != target:
            return (lo, hi-1)
        hi += 1
    return (lo, hi-1)