This groups each 3 elements in the order they appear:
new_list = [data_list[i:i+3] for i in range(0, len(data_list), 3)]
Give us a better example if it is not what you want.
More Related Contents:
- Find the sum of two lists of lists element-wise [closed]
- List comprehension on a nested list?
- Extract first item of each sublist
- Finding max value in the second column of a nested list?
- Comprehension on a nested iterables?
- Flattening a list recursively [duplicate]
- How can I use list comprehensions to process a nested list?
- Counting depth or the deepest level a nested list goes to
- How to zip two lists of lists
- Is there a way to ordinate numbers in a list?
- finding the biggest sequence of repeating numbers in a list
- How to append new line to the list
- Remove duplicate dict in list in Python
- How to efficiently compare two unordered lists (not sets) in Python?
- list to dictionary conversion with multiple values per key?
- Python – TypeError: ‘int’ object is not iterable
- Why doesn’t list have safe “get” method like dictionary?
- Does python have a sorted list?
- Summing elements in a list
- How to make a custom object iterable?
- How to access the elements of a 2D array?
- Why does a for-loop with pop-method (or del statement) not iterate over all list elements [duplicate]
- Why does using multiplication operator on list create list of pointers? [duplicate]
- Remove dictionary from list
- How to get the cartesian product of multiple lists
- Union find implementation using Python
- Loop through list with both content and index [duplicate]
- In Python, is there an elegant way to print a list in a custom format without explicit looping?
- Retrieve the two highest item from a list containing 100,000 integers
- Python find list lengths in a sublist