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
To provide a solution you can modify and run the following program to incorporate the new city Ancho... View full answer
Get step-by-step solutions from verified subject matter experts
