def mkDict(keyList, valueList, cond=None):
    '''
    Make a new dict out of two lists. The first list provides keys,
    the 2nd provides values. The cond is a function taking 2 arguments:
    key and value. Example: lambda k,v:v%2==0
    A valid item means its cond(key, value) is true. Only valid items
    are included in the returned dict. 

    >>> a
    [0, 1, 2, 3, 4]
    
    >>> b= [chr(x) for x in range(65,70)]
    >>> b
    ['A', 'B', 'C', 'D', 'E']
    
    >>> mkDict(b,a)
    {'A': 0, 'C': 2, 'B': 1, 'E': 4, 'D': 3}
    
    >>> mkDict(b,a,lambda x,y:y%2==0)
    {'A': 0, 'C': 2, 'E': 4}

    Note:
    mkDict(a,b) (without the conditional check) is equavilant to
    dict(zip(a,b)), which is much faster. If you know there's no
    conditional check, better use dict(zip(a,b)) instead.
    '''

    if cond==None:
        return dict(zip(keyList, valueList))        
    else:
        return dict( [(k,v) for k,v in zip(keyList, valueList) if cond(k,v)] )

    Make a new dict out of two lists. The first list provides keys,
    the 2nd provides values. The cond is a function taking 2 arguments:
    key and value. Example: lambda k,v:v%2==0
    A valid item means its cond(key, value) is true. Only valid items
    are included in the returned dict. 

    >>> a
    [0, 1, 2, 3, 4]
    
    >>> b= [chr(x) for x in range(65,70)]
    >>> b
    ['A', 'B', 'C', 'D', 'E']
    
    >>> mkDict(b,a)
    {'A': 0, 'C': 2, 'B': 1, 'E': 4, 'D': 3}
    
    >>> mkDict(b,a,lambda x,y:y%2==0)
    {'A': 0, 'C': 2, 'E': 4}

    Note:
    mkDict(a,b) (without the conditional check) is equavilant to
    dict(zip(a,b)), which is much faster. If you know there's no
    conditional check, better use dict(zip(a,b)) instead.
    
recipes/Python/278259_Dictionary_Tools/recipe-278259.py