Search⌘ K
AI Features

More Bad Input

Explore how to validate Roman numeral inputs in Python by implementing regular expressions and unit tests. Understand the rules of Roman numerals and ensure your from_roman() function properly handles invalid inputs. This lesson equips you with techniques to improve code reliability with precise input validation and custom exceptions.

We'll cover the following...

Now that the from_roman() function works properly with good input, it’s time to fit in the last piece of the puzzle: making it work properly with bad input. That means finding a way to look at a string and determine if it’s a valid Roman numeral. This is inherently more difficult than ...