<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def nelect(self):
 """ Gets the default number of electrons for a given structure. """

        # if structure is not sorted this can cause problems, so must take
        # care to remove redundant symbols when counting electrons
        site_symbols = list(set(self.poscar.site_symbols))
        nelect = 0.
        for ps in self.potcar:
            if ps.element in site_symbols:
                site_symbols.remove(ps.element)
                nelect += self.structure.composition.element_composition[
                              ps.element] * ps.ZVAL

        if self.use_structure_charge:
            return nelect - self.structure.charge
        else:
            return nelect