<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_spin_by_site(self, spins):
 """ Add spin states to a structure by site. Args: spins (list):
 List of spins E.g., [+5, -5, 0, 0] """

        if len(spins) != len(self.sites):
            raise ValueError("Spin of all sites must be "
                             "specified in the dictionary.")

        for site, spin in zip(self.sites, spins):
            new_sp = {}
            for sp, occu in site.species.items():
                sym = sp.symbol
                oxi_state = getattr(sp, "oxi_state", None)
                new_sp[Specie(sym, oxidation_state=oxi_state,
                              properties={'spin': spin})] = occu
            site.species = new_sp