Verification Log: 11_documentation.txt

Companion source example or verification log for the tutorial, preserved in full with user directory paths anonymized; actual execution scope is defined by the log itself.

doctest: attempted 2 examples, 0 failed
Help on function chunk in module __main__:

chunk(items: list, size: int) -> list[list]
    Split a list into fixed-size chunks.

    Args:
        items: The list to split.
        size: Chunk size; must be a positive integer.

    Returns:
        A list of chunked sublists; the final chunk may be shorter than size.

    Raises:
        ValueError: When size <= 0.

    Examples:
        >>> chunk([1, 2, 3, 4, 5], 2)
        [[1, 2], [3, 4], [5]]
        >>> chunk([], 3)
        []

Back to Tutorials Back to Learn →Back to top ↑
On this page
Tutorial diagram100%
Tutorial diagram