We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Make the regex intent clearer and allow use of named groups for debugimportrestart=r"^"thousands=r"(?P<thousands>M{0,3})"hundreds=r"(?P<hundreds>CM|CD|(D{0,1}C{0,3}))"tens=r"(?P<tens>XC|XL|(L{0,1}X{0,3}))"units=r"(?P<units>IX|IV|(V{0,1}I{0,3}))"end=r"$"regex_pattern=rf"{start}{thousands}{hundreds}{tens}{units}{end}"# Do not delete 'r'.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Validating Roman Numerals
You are viewing a single comment's thread. Return to all comments →