Created
March 14, 2018 00:07
-
-
Save dogac00/bf82da7acc9bef77cd8cf6b837c039d0 to your computer and use it in GitHub Desktop.
IP Validation @codewars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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