You are viewing a single comment's thread. Return to all comments →
thousand = 'M{0,3}' hundred = '(C[MD]|D?C{0,3})' ten = '(X[CL]|L?X{0,3})' digit = '(I[VX]|V?I{0,3})' regex_pattern = r"%s%s%s%s$" % (thousand, hundred, ten, digit) # Do not delete 'r'. import re print(str(bool(re.match(regex_pattern, input()))))
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 →