def Int_roman(n): st=("M","D","C","L","X","V","I") d=[1000,500,100,50,10,5,1] st1="" while n>0: d1=d+[n] d1.sort(reverse=True) n1=d1.index(n) l,m,r=(n1-1)/2*2,(n1-1)/2*2+1,(n1-1)/2*2+2 if n<1000 and n/d[r]*d[r]==d[l]-d[r]: st1=st1+st[r]+st[l] n=n-(d[l]-d[r]) elif n<1000 and n/d[r]*d[r]==d[m]-d[r]: st1=st1+st[r]+st[m] n=n-(d[m]-d[r]) else: st1=st1+st[n1]*(n/d[n1]) n=n%d[d1.index(n)] return st1def roman_Int(m): st=("M","D","C","L","X","V","I") d=[1000,500,100,50,10,5,1] n=0 for i in range(len(m)): if len(m)>1 and ist.index(m[i+1]): n=n-d[st.index(m[i])] else: n=n+d[st.index(m[i])] return n