0 out of 464 challenges solved
Write a Python function `long_words(n, sentence)` that takes an integer `n` and a string `sentence` as input. The function should return a list of words from the sentence that are longer than `n` characters. #### Example Usage ```python [main.nopy] print(long_words(3, "python is a programming language")) # Output: ['python', 'programming', 'language'] print(long_words(2, "writing a program")) # Output: ['writing', 'program'] print(long_words(5, "sorting list")) # Output: ['sorting'] ```
def long_words(n, sentence): """ Return a list of words from the sentence that are longer than n characters. Args: n (int): The minimum length of words to include. sentence (str): The input sentence. Returns: list: A list of words longer than n characters. """ # Split the sentence into words words = sentence.split() # Placeholder for the result result = [] # Iterate through words and filter based on length # Add your implementation here return result