Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q#4 Write a program that reads the contents of file Cities.txt into a list. The program should ask the user to enter the names of

Q#4 Write a program that reads the contents of file Cities.txt into a list. The program should ask the user to enter the names of two cities. (Tip: Keep in mind that the city#1 entered by the user may not exist in the list. In this case, you must show that city#1 was not found). Then, in the list, replace all occurrences of city #1 with city #2. At the end, show the updated list of cities. Handle any exceptions that may be raised in the program.

Cities.txt

Boston New York Chicago Chicago Chicago Pittsburgh Philadelphia Philadelphia Boston Philadelphia Boston Boston Boston Chicago Boston Cincinnati Cleveland New York New York New York Washington Pittsburgh St. Louis New York New York Philadelphia Philadelphia St. Louis New York New York St. Louis Detroit New York New York New Yotk New York Cincinnati New York St. Louis New York St. Louis Detroit St. Louis New York Cleveland New York New York New York New York New York New York Brooklyn New York Milwaukee New York Los Angeles Pittsburgh New York New York Los Angeles St. Louis Los Angeles Baltimore St. Louis Detroit New York Baltimore Pittsburgh Oakland Oakland Oakland Cincinnati Cincinnati New York

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

1. Describe the two branches of general equilibrium analysis.

Answered: 1 week ago