def validate_ip(ip):
    """ Validate if a string have an correct IP format.
        Args:
            ip (str):   The string to be verified.
        Returns:
            ip (str):   The string with a valid IP format.
        Raises:
            ValueError: In case the string hasn't a valid IP format.
    """
    splitted_ip = str(ip).split('.')
    if len(splitted_ip) != 4:
        raise ValueError("[!] Invalid IP!")
    for octet in splitted_ip:
        if (int(octet) < 0 or int(octet) > 255) or (len(octet) > 1 and octet.startswith('0')):
            raise ValueError("[!] Invalid IP!")
    return ip