Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

While using python: #Given a list strings containing city, state zip # with irregular spacing between the components #print this information in a nicely formatted

While using python:

#Given a list strings containing city, state zip # with irregular spacing between the components #print this information in a nicely formatted table table

def main(): mycities = ['Cape Girardeau, MO 63780','Columbia, MO 65201', 'Kansas City, MO 64108','Rolla,MO 65402', 'Springfield, MO65897','St Joseph, MO64504', 'St Louis,MO63111', 'Ames, IA 50010 ', 'Enid, OK 73773', 'West Palm Beach, FL 33412', 'International Falls, MN 56649', 'Frostbite Falls,MN 56650 ' ] # Print the table for c in mycities: print(c)

main()

1. Program needs to find the individual components [city, state, zip] in the string, then print them lined up in columns. Like this:

Cape Girardeau MO 63780 Columbia MO 65201 Kansas City MO 64108 Rolla MO 65402 Springfield MO 65897 St Joseph MO 64504 St Louis MO 63111 Ames IA 50010 Enid OK 73773 West Palm Beach FL 33412 International F MN 56649 Frostbite Falls MN 56650

2. Make it so that there is exactly one space after the longest city name and the start of the state column, like this:

Enid OK 73773 West Palm Beach FL 33412 International Falls MN 56649 Frostbite Falls MN 56650

3. Add comments before blocks of code, rather than at the end of a line.

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Networking is a two-way street. Discuss this statement.

Answered: 1 week ago