Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python language please, practice with regular expressions and string processing Part II: Determine a Package's Destination (10 points) Write a function package destination ), which

python language please, practice with regular expressions and string processing

image text in transcribedimage text in transcribedimage text in transcribed

Part II: Determine a Package's Destination (10 points) Write a function package destination ), which takes two arguments in the following order: 1. package.code: a string that might represent a valid shipping code on a package 2. country.codes: a dictionary that matches a country's code (a string) to the name of a country A validly formatted address is defined by the following components, in the given order: 1. three digits CSE 101 -Spring 2018 Lab #13 Page 3 2. a dash 3. three digits 4. a dash 5. one uppercase letter 6. one digit If the string is validly formatted, the function extracts the three-digit country code at the start of the string and uses it as a key in the country-codes dictionary. The country name associated with the key is returned by the function. If the package.code is invalidly formatted, or it is validly formatted but the extracted country code is not in the dictionary, the function returns the string error Hint: after verifying that the argument string matches the expected pattern, use the split ) method to extract the part of the string needed for the dictionary lookup

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_2

Step: 3

blur-text-image_3

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 Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions