<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on(self, event, new_state):
 """ add a valid transition to this state """

        if self.name == new_state.name:
            raise RuntimeError("Use loop method to define {} -> {} -> {}".format(self.name, event.name, new_state.name))
        self._register_transition(event, new_state)