Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to know how to do it using python I posted it twice last night but I was

ID: 3572655 • Letter: I

Question

I need to know how to do it using python I posted it twice last night but I was new so I didn't know how to post it correctly. also I tried to do it using python so many times but I couldn't know how to do it correctly. I get zeros in my answer which is wrong.

The following table contains the average travel t (in minutes) between several cities Travel time (in minute) A 0 127 236 387 476 530 B 127 0 110 265 328 486 C 236 110 0 345 159 D 387 265 159 424 295 E 476 328 295 424 t 515 F 530 486 345 295 515 First, create a 2d list called timelist which stores all the above information. Write a program which calculates the total time (in hour and minutes it takes to travel between 3 (three) cities. The user should enter the name of the cities Does your program work? (choose one) YES NO If yes, print the (final) content of your list:

Explanation / Answer

#Programme for finding time duration between 3 cites to travel
import sys

city=['A','B','C','D','E','F']; #city array holds city names
arr = [] #arr for holding distances
#appending user input data to multidimesional array
arr.append([0,127,236,387,476,530])
arr.append([127,0,110,265,328,486])
arr.append([236,110,0,159,295,345])
arr.append([387,265,159,0,424,295])
arr.append([530,486,345,295,515,0])
#Prompts for cities to travel
print("ASSUME CITY1 - A,CITY2 - B,CITY3 - C,CITY4 - D,CITY5 - E,CITY6 - F")
ch1 = input("Enter City1 Name: A | B | C | D | E | F ")

ch2 = input("Enter City2 Name: A | B | C | D | E | F ")

ch3 = input("Enter City3 Name: A | B | C | D | E | F ")

#finding duaration to travel 3 citeis
#index() function on llst returns position of city in list
duration=arr[city.index(ch1)][city.index(ch2)]+arr[city.index(ch2)][city.index(ch3)]
#print duration in mins
print ("Duration in mins : ",duration)
hrs=int(duration/60)
mins=int(duration%60)
print ("Hrs : ",hrs,"Mins : ",mins)


Output :

ASSUME CITY1 - A,CITY2 - B,CITY3 - C,CITY4 - D,CITY5 - E,CITY6 - F
Enter City1 Name: A | B | C | D | E | F
A
Enter City2 Name: A | B | C | D | E | F
C
Enter City3 Name: A | B | C | D | E | F
F
Duration in mins : 581
Hrs : 9 Mins : 41