All MicroEvals
Complete the following Python function: ```python from typi...
Create MicroEval

Complete the following Python function: ```python from typi...

Prompt

Complete the following Python function: ```python from typing import List, Optional def longest(strings: List[str]) -> Optional[str]: """ Out of list of strings, return the longest one. Return the first one in case of multiple strings of the same length. Return None in case the input list is empty. >>> longest([]) >>> longest(['a', 'b', 'c']) 'a' >>> longest(['a', 'bb', 'ccc']) 'ccc' """ ```

Answer guidance

Canonical solution (function body): if not strings: return None maxlen = max(len(x) for x in strings) for s in strings: if len(s) == maxlen: return s

Drag to resize
Drag to resize