I have multiple lists namely, `X`

, `Y`

, `VX`

, `VY`

, `R`

, `T`

, `KE`

, `PE`

, `TE`

, for which I need to delete their (i+1)th value off once their iterations break. The way I can do it currently is if I do:

```
del X[i+1:]
del Y[i+1:]
del VX[i+1:]
del VY[i+1:]
del R[i+1:]
del T[i+1:]
del KE[i+1:]
del PE[i+1:]
del TE[i+1:]
```

Which I think it looks rather ugly. Is there a way to minimize the use of lines in this case. Maybe a loop which does that but in just 1 or 2 lines?

Edit:

I didn’t want to include the body of my code because I’m aware that a lot of my colleagues are doing the same problem and I don’t want anyone to plagiarize. Anyway, here’s what I did.

```
def F_1(X):
return VX
def F_2(X):
return VY
def F_3(X, Y):
return -G*EM*X/((X**2 + Y**2)**(3/2))
def F_4(X, Y):
return -G*EM*Y/((X**2 + Y**2)**(3/2))
def RKutta(F_1, F_2, F_3, F_4, XSTART, YSTART, VXSTART, VYSTART):
N = 100000
X, Y = np.zeros([N+1]), np.zeros([N+1])
VX, VY = np.zeros([N+1]), np.zeros([N+1])
R, T = np.zeros([N+1]), np.zeros([N+1])
KE, PE, TE = np.zeros([N+1]), np.zeros(N+1), np.zeros([N+1])
X[0], Y[0] = XSTART, YSTART
VX[0], VY[0] = VXSTART, VYSTART
T[0] = 0
# KE[0], PE[0], TE[0] = KE, PE, TE
for i in range (1,N):
K_1X = F_1(VX[i-1])
K_1Y = F_2(VY[i-1])
K_1VX = F_3(X[i-1], Y[i-1])
K_1VY = F_4(X[i-1], Y[i-1])
K_2X = F_1(VX[i-1] + (H*K_1VX/2))
K_2Y = F_2(VY[i-1] + (H*K_1VY/2))
K_2VX = F_3(X[i-1] + (H*K_1X/2), Y[i-1] + (H*K_1Y/2))
K_2VY = F_4(X[i-1] + (H*K_1X/2), Y[i-1] + (H*K_1Y/2))
K_3X = F_1(VX[i-1] + (H*K_2VX/2))
K_3Y = F_2(VY[i-1] + (H*K_2VY/2))
K_3VX = F_3(X[i-1] + (H*K_2X/2), Y[i-1] + (H*K_2Y/2))
K_3VY = F_4(X[i-1] + (H*K_2X/2), Y[i-1] + (H*K_2Y/2))
K_4X = F_1(VX[i-1] + H*K_3VX)
K_4Y = F_2(VY[i-1] + H*K_3VY)
K_4VX = F_3(X[i-1] + H*K_3X, Y[i-1] + H*K_3Y)
K_4VY = F_4(X[i-1] + H*K_3X, Y[i-1] + H*K_3Y)
X[i] = X[i-1] + (H/6)*(K_1X + 2*K_2X + 2*K_3X + K_4X)
Y[i] = Y[i-1] + (H/6)*(K_2Y + 2*K_2Y + 2*K_3Y + K_4Y)
VX[i] = VX[i-1] + (H/6)*(K_1VX + 2*K_2VX + 2*K_3VX + 2*K_4VX)
VY[i] = VY[i-1] + (H/6)*(K_1VY + 2*K_2VY + 2*K_3VY + 2*K_4VY)
R[i] = ((X[i])**2 + (Y[i])**2)**(0.5)
T[i] = T[i-1] + H
KE[i] = ((VX[i]**2 + VY[i]**2)/2)
PE[i] = (-1*G*EM/R[i])
TE[i] = KE[i] + PE[i]
if R[i] < 6.371E6: #if orbit radius is less than Earth radius
break
for sublist in [X, Y, VX, VY, R, T, KE, PE, TE]:
del sublist[i+1:]
return X, Y, VX, VY, R, T, KE, PE, TE
X = 3.84E8
Y = 0
X, Y, VX, VY, R, T, KE, PE = RKutta(F_1, F_2, F_3, F_4, X, Y, VX, VY)
plt.plot(X, Y, label = "")
plt.xlabel("X distance (m)")
plt.ylabel("Y distance (m)")
plt.title("X against Y")
plt.legend()
plt.show()
```

read more