import itertools


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

    From: https://docs.python.org/3/library/itertools.html#recipes

    :param iterable: iterable
    :param n: item index
    :param default: default value
    :return: nth item of given iterable
    """

    return next(itertools.islice(iterable, n, None), default)