# Solutions for Form IP Address From String

• @Liam, submitted in Python 2, achived 100% score
``````def solve(s):
#Code here
A=s
n=len(A)
x=[]
for i in range(1,n-2):
for j in range(i+1,n-1):
for k in range(j+1,n):
a=A[:i]
b=A[i:j]
c=A[j:k]
d=A[k:]
if(len(a)<=3 and len(b)<=3 and len(c)<=3 and len(d)<=3):
e=int(a);f=int(b);g=int(c);h=int(d)
#print(a,b,c,d)
if(str(e)==a and str(f)==b and str(g)==c and str(h)==d):
#print(e,f,g,h)
if(e>=0 and e<=255 and f>=0 and f<=255 and g>=0 and g<=255 and h>=0 and h<=255):
s=""
s=a+"."+b+"."+c+"."+d
x.append(s)
return x
``````
• @Liam, submitted in Python 3, achived 100% score
``````def solve(s):
#Code here
A=s
n=len(A)
x=[]
for i in range(1,n-2):
for j in range(i+1,n-1):
for k in range(j+1,n):
a=A[:i]
b=A[i:j]
c=A[j:k]
d=A[k:]
if(len(a)<=3 and len(b)<=3 and len(c)<=3 and len(d)<=3):
e=int(a);f=int(b);g=int(c);h=int(d)
#print(a,b,c,d)
if(str(e)==a and str(f)==b and str(g)==c and str(h)==d):
#print(e,f,g,h)
if(e>=0 and e<=255 and f>=0 and f<=255 and g>=0 and g<=255 and h>=0 and h<=255):
s=""
s=a+"."+b+"."+c+"."+d
x.append(s)
return x

``````