Question: Two-dimensional list example: Driving distance between cities. The following example illustrates the use of a two-dimensional list in a distance between cities example. Run the

Two-dimensional list example: Driving distance between cities.

The following example illustrates the use of a two-dimensional list in a distance between cities example.

Run the following program, entering the text '1 2' as input to find the distance between LA and Chicago. Try other pairs. Next, try modifying the program by adding a new city, Anchorage, that is 3400, 3571, and 4551 miles from Los Angeles, Chicago, and Boston, respectively.

Note that the styling of the nested list in this example makes use of indentation to clearly indicate the elements of each list -- the spacing does not affect how the interpreter evaluates the list contents.



Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To provide a solution you can modify and run the following program to incorporate the new city Ancho... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!