code: def add_error_marker(text, position, start_line=1):
      
      indent = "    "
      lines = []
      caret_line = start_line
      for line in text.split("\n"):
          lines.append(indent + line)
  
          if 0 <= position <= len(line):
              lines.append(indent + (" " * position) + "^")
              caret_line = start_line
  
          position -= len(line)
          position -= 1  # for the newline
          start_line += 1
  
      return "\n".join(lines), caret_line
docs: Add a caret marking a given position in a string of input.
  
      Returns (new_text, caret_line).