• Iterable in Solutions


In quite a few problems the solution code template starts with 'import Iterable' and using Iterable to open the function.

For reference, below is example code from the 'chunking by' problem:

from collections.abc import Iterable

def chunking_by(items: list[int], size: int) -> Iterable[list[int]]:

I have spent some time searching via Google, but I can't find a clear explanation (or don't understand) what this code is doing and how it effects the code in the function. I have noticed then when I try to use len(items) i the function, I get the error message 'int object is not iterable'.

Can anyone help me to understand this code?