code: def add_oxidation_state_by_site(self, oxidation_states):
          
          if len(oxidation_states) != len(self.sites):
              raise ValueError("Oxidation states of all sites must be "
                               "specified.")
          for site, ox in zip(self.sites, oxidation_states):
              new_sp = {}
              for el, occu in site.species.items():
                  sym = el.symbol
                  new_sp[Specie(sym, ox)] = occu
              site.species = new_sp
docs: Add oxidation states to a structure by site.
  
          Args:
              oxidation_states (list): List of oxidation states.
                  E.g., [1, 1, 1, 1, 2, 2, 2, 2, 5, 5, 5, 5, -2, -2, -2, -2]