Compare Model 1
Prompt
Complete the following Python function: ```python from typing import List def filter_by_substring(strings: List[str], substring: str) -> List[str]: """ Filter an input list of strings only for ones that contain given substring >>> filter_by_substring([], 'a') [] >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a') ['abc', 'bacd', 'array'] """ ```
Answer guidance
Canonical solution (function body): return [x for x in strings if substring in x]
Drag to resize
Drag to resize
Drag to resize
Drag to resize
Drag to resize