def _convert ( tup , dictlist ) : di = { } for a , b in tup : di . setdefault ( a , [ ] ) . append ( b ) for key , val in di . items ( ) : dictlist . append ( ( key , val ) ) return dictlist
python 3 create a dictionary from a list of tuples
: param tup : a list of tuples : param di : a dictionary converted from tup : return : dictionary
def _convert(tup, dictlist):
    """
    :param tup: a list of tuples
    :param di: a dictionary converted from tup
    :return: dictionary
    """
    di = {}
    for a, b in tup:
        di.setdefault(a, []).append(b)
    for key, val in di.items():
        dictlist.append((key, val))
    return dictlist