Update chunk_into_n.md

This commit is contained in:
Angelos Chalaris
2020-10-13 19:09:35 +03:00
committed by GitHub
parent c4a0b8ca7e
commit 49c4e295a8

View File

@ -5,10 +5,10 @@ tags: list,intermediate
Chunks a list into `n` smaller lists.
- Use `math.ceil()` and `len()` to get the size of each chunk.
- Use `list()` and `range()` to create a new list of size `n`.
- Use `map()` to map each element of the new list to a chunk the length of `size`.
- If the original list can't be split evenly, the final chunk will contain the remaining elements.
- Use `math.ceil()` and `len()` to get the size of each chunk.
- Use `list()` and `range()` to create a new list of size `n`.
- Use `map()` to map each element of the new list to a chunk the length of `size`.
- If the original list can't be split evenly, the final chunk will contain the remaining elements.
```py
from math import ceil