Splits a list into sublists based on either a list of indices or a number of sections.
Project description
Splits a list into sublists based on either a list of indices or a number of sections.
Tested against Windows / Python 3.11 / Anaconda
pip install splitlistatindex
from splitlistatindex import list_split
l1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
l2 = [3, 5, 7, 8, 12]
# Split `l1` using a list of indices
result1 = list_split(l=l1, indices_or_sections=l2)
# result1 will be: [[0, 1, 2], [3, 4], [5, 6], [7], [8, 9]]
# Split `l1` into 3 sections
result2 = list_split(l=l1, indices_or_sections=3)
# result2 will be: [[0, 1, 2, 3], [4, 5, 6], [7, 8, 9]]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
splitlistatindex-0.10.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for splitlistatindex-0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcb918098a187452651eead61367b61f86adc8c04c1c16317ae0bda12d921957 |
|
MD5 | fda6c504db6e78fbec80eaf55579d08a |
|
BLAKE2b-256 | 1af0a81c88442e4222d34efe6aec83dda78ccbd92188d875a8831bdd7728a2a1 |