code: def truncate(string, maxchar):
      
      if maxchar < 4:
          raise TruncateError("Maxchar must be > 3")
  
      if len(string) <= maxchar:
          return string
      else:
          return string[:maxchar - 3] + "..."
docs: Truncate a string to a maximum number of characters.
  
      If the string is longer than maxchar, then remove excess
      characters and append an ellipses.
  
      Arguments:
  
          string (str): String to truncate.
          maxchar (int): Maximum length of string in characters. Must be >= 4.
  
      Returns:
  
          str: Of length <= maxchar.
  
      Raises:
  
          TruncateError: In case of an error.