from typing import List
from typing import Dict


def species_by_charge(state_ids: List[str], charges: List[int]) -> Dict[int, List[str]]:
    """Make a dict with charge as key, and lists of species as values.

    Parameters
    ----------
    state_ids - identifiers for states
    charges - charges for states

    Returns
    -------
    Dict with charge as keys, and lists that contain the names of microstates with that charge.
    """
    charge_dict = dict(zip(state_ids, charges))
    species_dict = dict()

    # Duplicates don't matter
    for value in charge_dict.values():
        species_dict[value] = list()

    for state_id, charge in charge_dict.items():
        species_dict[charge].append(state_id)

    return species_dict