(iterable, n)
| 6 | except ImportError: |
| 7 | |
| 8 | def batched(iterable, n): |
| 9 | # batched('ABCDEFG', 3) --> ABC DEF G |
| 10 | if n < 1: |
| 11 | raise ValueError('n must be at least one') |
| 12 | it = iter(iterable) |
| 13 | while batch := tuple(islice(it, n)): |
| 14 | yield batch |
no outgoing calls
no test coverage detected