I want to compute the travel time of a route by using a travel time matrix I already have. Specifically, I have a list of lists that indicates the routes' nodes. routes= [[1, 2, 3, -1, -1], [1, 2, 3, 4, -1]] The -1 indicates that the route ends. So, in this example I have 2 routes: Route 1: 1>2>3 Route 2: 1>2>3>4 Also, I have the following travel time matrix (list of lists): tt= [[0, 4, 5, 1], [5, 0, 9, 2], [1, 1, 0, 1], [1, 1, 1, 0]] So what I want to achieve is to estimate the travel time of the routes. The result is the following: Route 1= 4(1>2) + 9(2>3) + 0(because it's from 3 to -1) (=13) Route 2= 4(1>2) + 9(2>3) + 1(3>4) + 0(because it's from 4 to -1) (=14) Results can be stored in a list. Do you have any suggestions? Continue reading...