Intermediate
Compare versions as numbers
Write parse_version(text) that turns "2.10.0" into the tuple (2, 10, 0).
Write newest(versions) that returns the highest version string from a list, comparing as numbers (not as text).
Print newest(["2.9.0", "2.10.0", "2.1.5"]).
What Check tests
parse_version("2.10.0")is(2, 10, 0)newestpicks 2.10.0 over 2.9.0newest(["1.0.0"])returns the only item- Versions with different numbers of parts compare correctly
- A two-digit major version beats a one-digit one
- The program prints
2.10.0
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.