Update chunk_into_n.md

This commit is contained in:
Angelos Chalaris
2020-10-13 22:37:49 +03:00
committed by GitHub
parent 49c4e295a8
commit 4a6bd35d57

View File

@ -3,11 +3,11 @@ title: chunk_into_n
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`.
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.
```py