easy +8 pts

Parse numbered list

Convert a numbered markdown-style list into a list of clean string items.

Write a function `parse_numbered_list(text: str) -> list[str]` that takes a string containing a numbered list, where each line begins with a number followed by a period and a space (e.g., `1. `). The function should return a list of the item texts, with each text stripped of leading and trailing whitespace. Ignore any blank lines. The input will always contain at least one valid list item, and every non-empty line will be a valid numbered item (i.e., starts with `1. `, `2. `, etc.). The numbers are sequential starting at 1, but you should not rely on that — just remove the leading number, period, and exactly one space after the period, then keep the rest of the line. Do not modify the item text other than stripping surrounding whitespace.

Constraints

The input length is at most 1000 characters. Lines are separated by `\n`. No extra leading or trailing spaces on a line except the one after the period. The item text may contain any printable characters.

Example

>>> parse_numbered_list('1. First item\n2. Second item\n3. Third')
['First item', 'Second item', 'Third']
>>> parse_numbered_list('1. Apple\n\n2. Banana')
['Apple', 'Banana']
8 points ~12 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Split the input into lines using `text.splitlines()`.
Skip lines that are empty or contain only whitespace.
For each line, find the first period and strip everything before it, then strip the remainder.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.