Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python Split list into chunks using lambda Method

# Split a Python List into Chunks using lambda function

sample_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
chunk_size = 2

lst= lambda sample_list, chunk_size: [sample_list[i:i+chunk_size] for i in range(0, len(sample_list), chunk_size)]
result=lst(sample_list, chunk_size)
print(result)
Source by itsmycode.com #
 
PREVIOUS NEXT
Tagged: #Python #Split #list #chunks #lambda #Method
ADD COMMENT
Topic
Name
4+2 =