so after that part, I have to make a function that returns a list of total distances between each of the cities in the cities list (a list of pair-lists) and I have to have it so the function calculates the total distances between each city and all the other cities. The index of the results list should correspond to the index in the cities list so that index i in the results list represents the total distance between cities[i] and all the other cities.
I understand that it's telling me what to do but don't understand how to write it out :(
right now I have this as the function to calaculate the total distance but it seems as if i'm missing something..
-
-
def total_distances(cities):
-
distance = 0.0
-
for i in cities():
-
distance = distance + get_distance(x1,y1,x2,y2)
-
return distance
-
and this is my previous function that I used in the total_distance function that calculates the distance between two cities
-
def get_distance(x1,y1,x2,y2):
-
return sqrt(((x2-x1)**2) + ((y2-y1)**2))
-