Fixed  issue 'Python code modifies loop while iterating over it #62492' 
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this [failed invocation](https://github.com/tensorflow/tensorflow/pull/62496/checks?check_run_id=19105729735) of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.
Fixed #62492 issue :
In tensorflow/python/training/saver.py, in _RecordLastCheckpoint:
# Remove first from list if the same name was used before.
for p in self._last_checkpoints:
  if latest_save_path == self._CheckpointFilename(p):
    self._last_checkpoints.remove(p)
This modifies the _last_checkpoints list while iterating over it, causing the loop to skip steps.

Solution:

for p in self._last_checkpoints[:]:
  if latest_save_path == self._CheckpointFilename(p):
     self._last_checkpoints.remove(p)
Doing this will pass a copy of the list for checking then modyfing the original list seperately