from typing import Counter


def list_to_dict(lst, attr):
    """
    Convert a list of dictionaries into a dictionary

    :param list[dict] lst: A list of dictionaries, all containing the `attr` key
    :param attr: The key to indicate the element in the resulting dict
    :return: A dictionary of dictionaries
    """
    if Counter(elem[attr] for elem in lst).most_common(1)[0][1] > 1:
        raise ValueError("""
        The dictionary can't be created unambigously. 
        More than one element contains the same {}""".format(attr))
    return {elem[attr]: elem for elem in lst}