Created
March 3, 2026 16:21
-
-
Save pschanely/73798fd56513f82abbf29df24ca4df4f to your computer and use it in GitHub Desktop.
Shared via CrossHair Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| from typing import Optional | |
| def parse_year(yearstring: str) -> Optional[int]: | |
| ''' | |
| Something is wrong with this year parser! Can you guess what it is? | |
| post: __return__ is None or 1000 <= __return__ <= 9999 | |
| ''' | |
| return int(yearstring) if re.match('[1-9][0-9][0-9][0-9]', yearstring) else None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment