Split Into List Into Even Chunks

[Solved] Split Into List Into Even Chunks | Perl - Code Explorer | yomemimo.com
Question : Python Split list into chunks using List Comprehension

Answered by : itsmycode

# Split a Python List into Chunks using list comprehensions
sample_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
chunk_size=2
result=[sample_list[i:i + chunk_size] for i in range(0, len(sample_list), chunk_size)]
print(result)

Source : https://itsmycode.com/python-split-list-into-chunks/ | Last Update : Wed, 15 Dec 21

Question : split into list into even chunks

Answered by : tender-toucan-cf32s9kwijxl

def chunks(l, n): n = max(1, n) return (l[i:i+n] for i in range(0, len(l), n))

Source : https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks | Last Update : Sat, 05 Jun 21

Answers related to split into list into even chunks

Code Explorer Popular Question For Perl