Group Equal consecutive Group Equal consecutive
English RU

Given a list of elements, create and return a list whose elements are lists that contain the consecutive runs of equal elements of the original list. Note that elements that aren’t duplicated in the original list should become singleton lists in the result, so that every element gets included in the resulting list of lists.

Input: List of str and int.

Output: List of lists of str and int


group_equal([1, 1, 4, 4, 4, "hello", "hello", 4]) == [[1,1],[4,4,4],["hello","hello"],[4]]
group_equal([1, 2, 3, 4]) == [[1], [2], [3], [4]]
group_equal([1]) == [[1]]
group_equal([]) == []

The mission was taken from Python CCPS 109 Fall 2018. It is taught for Ryerson Chang School of Continuing Education by Ilkka Kokkarinen