Light Mode
Dark Mode
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?

Thanks

  • code_review
  • python
Created: Feb. 2, 2023, 4:03 a.m.
Updated: Feb. 2, 2023, 6:49 a.m.
0
10
User avatar
bn09whg