Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python: define and invoke main, don't use if __name__ == '__main__':, and also do not hard code, it asks so it's about inputs. Write

In Python: define and invoke main, don't use if __name__ == '__main__':, and also do not hard code, it asks so it's about inputs.

image text in transcribed

Write a program that asks the user for the name of file of addresses and a name of an output file. Your program should replace all occurrences of "NY" with "New York", all occurrences of "NJ" with "New Jersey", and all occurrences of "CT" with "Connecticut" and write the results to the output file. For example, if the input file contains: from wikipedia: NY-NJ-CT Tri-State Area The NY metropolitan area includes the most populous city in the United States (NY City); counties comprising Long Island and the Mid- and Lower Hudson Valley in the state of New York; the five largest cities in NJ and their vicinities; six of the seven largest cities in CT and their vicinities; and five counties in Northeast Pennsylvania. Then the output file should be: from wikipedia: New York-New Jersey-Connecticut Tri-State Area The New York metropolitan area includes the most populous city in the United States (New York City); counties comprising Long Island and the Mid- and Lower Hudson Valley in the state of New York; the five largest cities in New Jersey and their vicinities; six of the seven largest cities in Connecticut and their vicinities; and five counties in Northeast Pennsylvania. Hint: do each replacement one-by-one, that is, first get your program to replace all the "NY"s with "New York's and then go on to the next states

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_2

Step: 3

blur-text-image_3

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions