def _valid_ip(ip_address):
 octets = ip_address.split('.')
 if (len(octets) != 4):
  return False
 for (i, octet) in enumerate(octets):
  try:
   octets[i] = int(octet)
  except ValueError:
   return False
 (first_octet, second_octet, third_octet, fourth_octet) = octets
 if (first_octet < 1):
  return False
 elif (first_octet > 223):
  return False
 elif (first_octet == 127):
  return False
 if ((first_octet == 169) and (second_octet == 254)):
  return False
 for octet in (second_octet, third_octet, fourth_octet):
  if ((octet < 0) or (octet > 255)):
   return False
 return True

def _valid_ip ( ip_address ) : octets = ip_address . split ( '.' ) if ( len ( octets ) != 4 ) : return False for ( i , octet ) in enumerate ( octets ) : try : octets [ i ] = int ( octet ) except ValueError : return False ( first_octet , second_octet , third_octet , fourth_octet ) = octets if ( first_octet < 1 ) : return False elif ( first_octet > 223 ) : return False elif ( first_octet == 127 ) : return False if ( ( first_octet == 169 ) and ( second_octet == 254 ) ) : return False for octet in ( second_octet , third_octet , fourth_octet ) : if ( ( octet < 0 ) or ( octet > 255 ) ) : return False return True
check if the ip address is valid return either true or false .