I want to pick the pair of 3 elements from list and so on . How can I do this ?
Example:
array = [10, 5, 2, 7, 8, 7]
Output:
[[10, 5, 2], [7, 8, 7]]
My code:
array = [10, 5, 2, 7, 8, 7]
new_list = [array[i:i+3] for i in range(len(array))]
I want to pick the pair of 3 elements from list and so on . How can I do this ?
Example:
array = [10, 5, 2, 7, 8, 7]
Output:
[[10, 5, 2], [7, 8, 7]]
My code:
array = [10, 5, 2, 7, 8, 7]
new_list = [array[i:i+3] for i in range(len(array))]