def iterate_ngrams(text, n):
    """Generator to yield ngrams in ``text``.

    Example:
        >>> for ngram in iterate_ngrams("example", 4):
        ...     print(ngram)
        exam
        xamp
        ampl
        mple

    Args:
        text (str): text to iterate over
        n (int): size of window for iteration

    Returns:
        Generator expression to yield the next ngram in the text

    Raises:
        ValueError: If n is non positive
    """
    if n <= 0:
        raise ValueError("n must be a positive integer")

    return [text[i: i + n] for i in range(len(text) - n + 1)]
Generator to yield ngrams in ``text``.

    Example:
        >>> for ngram in iterate_ngrams("example", 4):
        ...     print(ngram)
        exam
        xamp
        ampl
        mple

    Args:
        text (str): text to iterate over
        n (int): size of window for iteration

    Returns:
        Generator expression to yield the next ngram in the text

    Raises:
        ValueError: If n is non positive