def assign_terms(atoms, term_dict):
    """Assign polynomial terms to each atom.

    :param atoms:  list of Mol2Atom atoms
    :type atoms:  list
    :param term_dict:  dictionary of polynomial terms
    :type term_dict:  dict
    :return:  modified list of atoms
    :rtype:  list
    """
    for atom in atoms:
        atom_type = atom.type.upper()
        if atom_type == "O.3":
            atom_type = "O.OH"
        try:
            atom.poly_terms = term_dict[atom_type]
        except KeyError:
            raise KeyError(
                f"Unable to find polynomial terms for atom type {atom_type}"
            )
    return atoms