Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started