import itertools


def nth(iterable, n, default=None):
    """ Returns the nth item or a default value.

    This code is mildly adapted from the documentation.

    N.B. This returns the *base-0* nth item in the iterator. For example, 
    nth(range(10), 1) returns 1.
    """
    return next(itertools.islice(iterable, n, None), default)