def validate_and_normalize_ip(ip):
 new_ip = ip.lower()
 if is_valid_ipv4(new_ip):
  return new_ip
 elif is_valid_ipv6(new_ip):
  return expand_ipv6(new_ip)
 else:
  raise ValueError(('Invalid ip %s' % ip))

def validate_and_normalize_ip ( ip ) : new_ip = ip . lower ( ) if is_valid_ipv4 ( new_ip ) : return new_ip elif is_valid_ipv6 ( new_ip ) : return expand_ipv6 ( new_ip ) else : raise ValueError ( ( 'Invalid ip %s' % ip ) )
return normalized ip if the ip is a valid ip .