<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_outcars_and_structures(cls, outcars, structures, calc_ionic_from_zval=False):
 """ Create Polarization object from list of Outcars and Structures in order of nonpolar to polar. Note, we recommend calculating the ionic dipole moment using calc_ionic than using the values in Outcar (see module comments). To do this set calc_ionic_from_zval = True """

        p_elecs = []
        p_ions = []

        for i, o in enumerate(outcars):
            p_elecs.append(o.p_elec)
            if calc_ionic_from_zval:
                p_ions.append(
                    get_total_ionic_dipole(structures[i], o.zval_dict))
            else:
                p_ions.append(o.p_ion)
        return cls(p_elecs, p_ions, structures)