Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The format_address function separates out parts of the address string into new strings: house_number and street_name, and returns: house number X on street named Y.

The format_address function separates out parts of the address string into new strings: house_number and street_name, and returns: "house number X on street named Y". The format of the input string is: numeric house number, followed by the street name which may contain numbers, but never by themselves, and could be several words long. For example, "123 Main Street", "1001 1st Ave", or "55 North Center Drive".

def format_address(address_string): # Declare variables

# Separate the address string into parts

# Traverse through the address parts for i, v in enumerate(address_string): # Determine if the address part is the # house number or part of the street name

# Does anything else need to be done # before returning the result? # Return the formatted string return "house number {} on street named {}".format({})

print(format_address("123 Main Street")) # Should print: "house number 123 on street named Main Street"

print(format_address("1001 1st Ave")) # Should print: "house number 1001 on street named 1st Ave"

print(format_address("55 North Center Drive")) # Should print "house number 55 on street named North Center Drive"

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

More Books

Students also viewed these Databases questions

Question

How far do you want to progress?

Answered: 1 week ago