def netmask_to_cidr(netmask):
    """ 
    Convert netmask to cidr format

    Notes:
        code from https://stackoverflow.com/a/43885814

    Args:
        netmask (string): netmask address

    Returns:
        int: cidr value
    """
    return sum([bin(int(x)).count('1') for x in netmask.split('.')])