0 out of 464 challenges solved
Write a function `pair_wise` that takes a list of items as input and returns a list of tuples, where each tuple contains a pair of consecutive items from the input list. #### Example Usage ```python [main.nopy] pair_wise([1, 2, 3, 4]) # Output: [(1, 2), (2, 3), (3, 4)] pair_wise(['a', 'b', 'c']) # Output: [('a', 'b'), ('b', 'c')] pair_wise([5]) # Output: [] ``` #### Constraints - The input list can contain any type of elements. - If the input list has fewer than 2 elements, return an empty list.
def pair_wise(l1): """ Returns a list of tuples containing consecutive pairs of elements from the input list. Args: l1 (list): The input list. Returns: list: A list of tuples with consecutive pairs. """ # Initialize an empty list to store the pairs result = [] # Iterate through the list to form pairs # Placeholder for implementation return result