I recently completed a course task in which I had to split a Python
list into equal-sized chunks or bins, I achieved this using the
range() function by specifying all the arguments (start, stop, step). Here is the code for it:
lst = [1,2,3,4,5,6,7,8,9,10] for idx in range(0, len(lst), 2): print(lst[idx : idx + 2])
In this code, I split the
list into lists each of size
2, I was wondering if there are different methods of doing the same thing, if there are, please provide them below using an example code.