0 out of 464 challenges solved
Write a Python function `find_tuples` that takes a list of tuples and an integer `k` as input. The function should return a new list containing only those tuples where all elements are divisible by `k`. #### Example Usage ```python [main.nopy] # Example 1 input_list = [(6, 24, 12), (7, 9, 6), (12, 18, 21)] k = 6 print(find_tuples(input_list, k)) # Output: [(6, 24, 12)] # Example 2 input_list = [(5, 25, 30), (4, 2, 3), (7, 8, 9)] k = 5 print(find_tuples(input_list, k)) # Output: [(5, 25, 30)] # Example 3 input_list = [(7, 9, 16), (8, 16, 4), (19, 17, 18)] k = 4 print(find_tuples(input_list, k)) # Output: [(8, 16, 4)] ``` #### Constraints 1. The input list will contain tuples of integers. 2. The integer `k` will be a positive integer. 3. The function should handle an empty list gracefully, returning an empty list.
def find_tuples(test_list, k): """ Filters tuples from the list where all elements are divisible by k. Args: test_list (list of tuples): The list of tuples to filter. k (int): The divisor. Returns: list of tuples: A list containing tuples where all elements are divisible by k. """ # Placeholder for the solution pass