ABOUT ME

My photo
Rajahmundry, AndhraPradesh, India
whatever the codes i have posted in past and i will be post in future are my own basic logic's you can also write the code in your own logic in different manner.so if have any doubts u can also contact me personally , you can catch my MAIL ID in about section.and also u can ask me in comment section.
in future i will post different  questions and its codes.so please stay tuned to my blog.  


try:
    a=input()
    x=0
    for i in a:
        if int(i)==1 or int(i)==0:
            x+=1
    if x==len(a):
        z={0:4,1:2,2:1}
        b=[int(i) for i in a]
        d=[[]]
        e=0
        for i in range(len(a)-1,-1,-1):
            d[e].insert(0,b[i])
            if len(d[e])==3 and i!=0:
                d.append([])
                e+=1
        i,c,f,g,h,j=0,0,-1,0,[],0
        while True:
            if len(d[i])!=3:
                d[i].insert(0,0)
            else:
                i+=1
            if i==len(d):
                break
        d.reverse()
        while True:
            while True:
                f+=1
                if d[c][j]==1:
                    g=g+z[f]
                    j+=1
                else:
                    j+=1
                if f==2:
                    c+=1
                    h.append(str(g))
                    g,j=0,0
                    f=-1
                if c==len(d):
                    break
            print(int("".join(h)))
            break
    else:
        print("ERROR")
except:
    print("ERROR")


NOTE: IF YOU HAVE ANY DOUBTS YOU CAN ASK ME IN COMMENTS SECTION.




















         1.write a python program for the above given question.

a=input()
s=0
b={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
c=[i for i in a]
if len(c)%2==0:
    for j in range(0,len(c)//2+1,2):
        if b[c[j]]>=b[c[j+1]]:
            s=s+abs(b[c[j]]+b[c[j+1]])
        else:
            s=s+abs(b[c[j]]-b[c[j+1]])
else:
    d=c[0]
    del(c[0])
    for j in range(0,(len(c)//2)+1,2):
        s=s+abs(b[c[j]]-b[c[j+1]])       
    s=s+b[d]
print(s)   
    
NOTE: IF U HAVE ANY DOUBTS YOU CAN  ASK IN COMMENT SECTION.