code: def safe_list_set(plist, idx, fill_with, value):
      
  
      try:
          plist[idx] = value
          return
      except IndexError:
          pass
  
      # Fill in the missing positions. Handle negative indexes.
      end = idx + 1 if idx >= 0 else abs(idx)
      for _ in range(len(plist), end):
          if callable(fill_with):
              plist.append(fill_with())
          else:
              plist.append(fill_with)
  
      plist[idx] = value
docs: Sets:
  
      ```
      plist[idx] = value
      ```
  
      If len(plist) is smaller than what idx is trying
      to dereferece, we first grow plist to get the needed
      capacity and fill the new elements with fill_with
      (or fill_with(), if it's a callable).