Python 3, 100 97 96 94 93 91 9190 bytes
- saved 4+2 bytes: use of
def
; array as default parameter reduced an indentation space; unwanted variable declaration removed
- @shooqie saved 1 byte
a%=
shorthand
- saved 2 bytes: rearranged and braces in
(a//i)
got removed
- @Wondercricket saved 1 byte: move the array from default parameter to within the function which removed
[]
at the cost of one indentation space, thus saving 1 byte.
def f(a,b=[1000):
b=1000,500,100,50,10,5,1]):1
for i in b:print(end=a//i*'MDCLXVI'[b.index(i)]);a%=i
Try it online!Try it online!