def add_element(dic, key, val):
    """
        given a dictionary containing lists and a key for that dictionary,
          appends val to the list at that key if it already exists,
          or else creates the list at that key with the given element
        returns the dict
    """
    if key in dic:
        dic[key].append(val)
    else:
        dic[key] = [val]
    return dic