import socket


def check_ip(ip, last=False):
    """
    Checks to see if the given IP is v4 or v6

    Args:
        ip: The ip string to be checked
        last: A base case to stop recursion

    Returns:
        If IP is matched as either v4 or v6 a string is returned, else False
    """
    ip_type = (socket.AF_INET, "v4") if not last else (socket.AF_INET6, "v6")
    try:
        socket.inet_pton(ip_type[0], ip)
        return ip_type[1]
    except OSError:
        if last:
            return False
        return check_ip(ip, True)