format_destination.format_destination

format_destination.format_destination(city, country_code)

Normalize destination names into the format: “City, COUNTRY_CODE”.

Rules: - city and country_code must be non-empty strings after stripping - country_code must be exactly 2 alphabetic letters - city is title-cased; country_code is upper-cased

Parameters

Name Type Description Default
city str City name (e.g., “vancouver”). required
country_code str Two-letter country code (e.g., “ca”, “FR”). required

Returns

Name Type Description
str Formatted destination string: “City, COUNTRY_CODE”.

Raises

Name Type Description
ValueError If inputs are empty after stripping or country_code is invalid.
TypeError If inputs are not strings.

Examples

>>> from travelpy.format_destination import format_destination
>>> format_destination("vancouver", "ca")
'Vancouver, CA'
>>> format_destination("  paris ", " fr ")
'Paris, FR'
>>> format_destination("TOKYO", "jp")
'Tokyo, JP'