try:
if len(IP.split('.')) == 4:
print(IP)
if all([bool(1) if(str(int(s)) == s and 0 <= int(s) <= 255) else bool(0) for s in IP.split('.')]):
return "IPv4"
if len(IP.split(':')) == 8:
if all([bool(1) if(len(s) <= 4 and int(s, 16) >= 0) else bool(0) for s in IP.split(':')]):
return "IPv6"
except:
return "Neither"
return "Neither"