Question: please write this code in python and start with def street_addresses(addresses): Part I: Validate Street Addresses (10 points) Write a function street.addresses), which takes a

 please write this code in python and start with def street_addresses(addresses):

Part I: Validate Street Addresses (10 points) Write a function street.addresses), which

takes a single argument addresses, which is a list of strings The

please write this code in python and start with

def street_addresses(addresses):

Part I: Validate Street Addresses (10 points) Write a function street.addresses), which takes a single argument addresses, which is a list of strings The function analyzes each string, and, if the string's format matches the pattern of a valid street address as described below, the function appends the string's index in addresses into a returned list. A validly formatted address is defined by the following components, in the given order: 1. one or more digits 2. exactly one space 3. an uppercase letter, followed by any combination of uppercase letters, lowercase letters and spaces 4. exactly one space 5. the word ' Street', 'Road' or 'Path', capitalized exactly as given 6. optionally, the following text: a. exactly one space b. the string 'Apt.', capitalized exactly as given c. exactly one space d. exactly one uppercase letter Examples of validly formatted addresses are ' 58 Gnarled Oak Street' and ' 173 East Main Road Apt. Q Suppose the following list were passed as addresses ['21 Main Street', '12 Main Drive', '5 Elm Apt. E','6 Elm Path Apt. 5'1l The function would return [0, 3] because only the first and last strings in this example match the pattern defined above. Part I: Validate Street Addresses (10 points) Write a function street.addresses), which takes a single argument addresses, which is a list of strings The function analyzes each string, and, if the string's format matches the pattern of a valid street address as described below, the function appends the string's index in addresses into a returned list. A validly formatted address is defined by the following components, in the given order: 1. one or more digits 2. exactly one space 3. an uppercase letter, followed by any combination of uppercase letters, lowercase letters and spaces 4. exactly one space 5. the word ' Street', 'Road' or 'Path', capitalized exactly as given 6. optionally, the following text: a. exactly one space b. the string 'Apt.', capitalized exactly as given c. exactly one space d. exactly one uppercase letter Examples of validly formatted addresses are ' 58 Gnarled Oak Street' and ' 173 East Main Road Apt. Q Suppose the following list were passed as addresses ['21 Main Street', '12 Main Drive', '5 Elm Apt. E','6 Elm Path Apt. 5'1l The function would return [0, 3] because only the first and last strings in this example match the pattern defined above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!