def subdict(keys, dict_):
    """
    Creates a subdictionary given a list of keys and a dictionary.

    Parameters
    ----------
    keys : list
        Keys to extract from `dict_`.
    dict_ : dict
        The dictionary from which to extract values.

    Returns
    -------
    dict
        A dictionary whose elements are a subset of `dict_`'s.

    Raises
    ------
    KeyError
        If any item in `keys` is not present in `dict_`.

    Examples
    --------
    >>> a = {'one': 1, 'two': 2, 'three': 3, 'four': 4}
    >>> subdict(['two', 'four'], a)
    {'two': 2, 'four': 4}
    >>> subdict(['five'], a)
    Traceback (most recent call last):
        ...
    KeyError: 'five'

    """
    return {key: dict_[key] for key in keys}