Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

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

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

Q.1. Health issues caused by adulteration data ?

Answered: 1 week ago

Question

1. Traditional and modern methods of preserving food Articles ?

Answered: 1 week ago

Question

What is sociology and its nature ?

Answered: 1 week ago

Question

What is liquidation ?

Answered: 1 week ago