Skip to content

Instantly share code, notes, and snippets.

@dogac00
Created March 14, 2018 00:07
Show Gist options
  • Save dogac00/bf82da7acc9bef77cd8cf6b837c039d0 to your computer and use it in GitHub Desktop.
Save dogac00/bf82da7acc9bef77cd8cf6b837c039d0 to your computer and use it in GitHub Desktop.
IP Validation @codewars
def is_valid_IP(string):
if(string==""):
return False
string=string.split('.')
count = 0
for i in string:
if(i[0]=="0" and len(i)!=1):
return False
elif(i.isdigit()==False):
return False
elif(int(i)<0 or int(i)>255):
return False
count+=1
if(count!=4):
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment