Implement a generator that groups consecutive identical elements from an iterable.
Constraints
Example
>>> list(groupby_consecutive([1, 1, 2, 3, 3, 3]))
[[1, [1, 1]], [2, [2]], [3, [3, 3, 3]]]
>>> list(groupby_consecutive("aabbbaa"))
[['a', ['a', 'a']], ['b', ['b', 'b', 'b']], ['a', ['a', 'a']]]
>>> list(groupby_consecutive([]))
[]
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints