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.
Please do subscribe my blog for more updates regarding python codes...
ReplyDeleteThank you for sharing.
ReplyDeleteData Science Online Training
Salesforce Online Training