easy +10 pts

Parse Version SemVer

Split a semantic version string into major, minor, and patch numbers.

Write a function `parse_semver(version: str) -> tuple[int, int, int]` that takes a semantic version string (e.g., `'1.2.3'`) and returns a tuple of three integers representing the major, minor, and patch numbers. The input will always be a string of the form `X.Y.Z`, where X, Y, Z are non-negative integers. No extra characters or labels are included. There are no leading or trailing spaces.

Constraints

Input length ≤ 20 characters. X, Y, Z each fit in a standard integer. You may assume the input is always well-formed as described.

Example

>>> parse_semver('1.2.3')
(1, 2, 3)
>>> parse_semver('0.0.0')
(0, 0, 0)
>>> parse_semver('10.20.30')
(10, 20, 30)
10 points ~15 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use the `split('.')` method on the input string.
Convert each part to an integer with `int()`.
Return the three integers as a tuple.
The input is guaranteed to have exactly two dots.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.