0 out of 464 challenges solved
Write a function `pack_consecutive_duplicates` that takes a list of elements and groups consecutive duplicate elements into sublists. The function should return a new list where each sublist contains consecutive duplicates from the input list. #### Example Usage ```python [main.nopy] pack_consecutive_duplicates([1, 1, 2, 3, 3, 3, 4]) # Output: [[1, 1], [2], [3, 3, 3], [4]] pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'c', 'd']) # Output: [['a', 'a'], ['b'], ['c', 'c'], ['d']] ```
from itertools import groupby def pack_consecutive_duplicates(input_list): """ Groups consecutive duplicate elements in the input list into sublists. Args: input_list (list): The list of elements to process. Returns: list: A list of sublists, where each sublist contains consecutive duplicates. """ # Implement the function logic here pass