code: def invert(self):
          
          for state in self.states:
              if state.final:
                  state.final = False
              else:
                  state.final = True
docs: Inverts the DFA final states