import socket


def getIpVersion(address):
    """
    Input Param : IP address.
    Output Param: IP address version.
                  Returns 0 if IP address is invalid.
                  Returns 4/6 if IP address is V4/V6 respectively.
    """

    ipVersion = 0

    try:
        socket.inet_pton(socket.AF_INET, address)
        ipVersion = 4
    except:
        pass

    try:
        socket.inet_pton(socket.AF_INET6, address)
        ipVersion = 6
    except:
        pass

    return ipVersion