code: def append_to_history(self):
          
          # Validate first. If not valid, set validation exception.
          if not self.validate():
              return
  
          # Save at the tail of the history. (But don't if the last entry the
          # history is already the same.)
          if self.text and (not len(self.history) or self.history[-1] != self.text):
              self.history.append(self.text)
docs: Append the current input to the history.
          (Only if valid input.)