import math
with open("input.txt", "r") as file:
list = []
for line in file:
list += [line.strip()]
list1 = list[0].split(" ")
a = int(list1[0])
b = int(list1[1])
list2 = []
list3 = []
d = a + 1
c = 1
for i in range(1, a+1):
list2.append(list[c])
c = c + 1
for i in range(d+1, a+b+2):
list3.append(list[d])
d = d + 1
e = 0
f = 0
g = 1000000000000000
list6 = []
for i in range(0, b):
for i in range(1, a):
list4 = list3[e].split(" ")
x = int(list4[0])
y = int(list4[1])
list5 = list2[f].split(" ")
x1 = int(list5[0])
y1 = int(list5[1])
distance = math.sqrt(math.pow((x1 - x), 2) + math.pow((y1 - y), 2))
list4.clear()
list5.clear()
f = f + 1
if distance < g:
g = distance
e = e + 1
list6.append(g)
print(list6)
When I start the program, I always get "IndexError: list index out of range". Can someone help me fix the problem. The error is in line 36.
list5 = list2[f].split(" ")
IndexError: list index out of range