Here is code that demonstrates how you can save the coordinates of the first and last points of the chain in two separate lists after every step:
first_point_coords = [ ]
last_point_coords = [ ]
for step in range(5000):
# make the chain move here
# update the coordinates of the first and last points
first_point_coords.append((first_point_x, first_point_y))
last_point_coords.append((last_point_x, last_point_y))
This code initializes two empty lists: first_point_coords and last_point_coords. It then loops through 5000 steps, updating the coordinates of the first and last points after each step. The updated coordinates are then appended to the appropriate lists.
You may need to modify this code to fit your specific needs, such as by changing the variables first_point_x, first_point_y, last_point_x, and last_point_y to the appropriate names and values in your code.