Roman Numerals

easy
Unit 1 · Strings I0/3 to milestone

Convert between integers (1 to 3999) and Roman numerals, using subtractive notation (IV = 4, XC = 90, CM = 900).

Implement to_roman(n) and from_roman(s). from_roman must reject invalid numerals such as "IIII", "VX" or "IC" with a ValueError. A neat trick: convert, then check that converting back gives the same string. to_roman raises ValueError outside 1–3999.

#strings#parsing2 visible + 2 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Roman Numerals · TechGradify