runtime
93 / 500
question 93 Fundamentals Integration · easy

Print-ready shipping label

Orders arrive with names and addresses exactly as customers typed them. The label printer needs three clean lines: the name in title case, the street (plus the unit, if there is one), and the city in capitals with the state code and ZIP.

Functionshipping_label(order)
order{"customer": {"first", "last"}, "address": {"street", "city", "state", "zip"}}; the address may also have a "unit"
Returnsone text of three lines joined by \n: First Last, street or street, unit, CITY, ST ZIP
Cleaningevery field is stripped; names in title case; city and state in capitals; a unit that is blank counts as no unit
Examples
callshipping_label({'customer': {'first': ' nora', 'last': 'GARCIA '}, 'address': {'street': '12 Elm St', 'city': 'houston', 'state': 'tx', 'zip': ' 77002'}})returns'Nora Garcia\n12 Elm St\nHOUSTON, TX 77002'
callshipping_label({'customer': {'first': 'jamal', 'last': 'walker'}, 'address': {'street': '400 Pine Ave', 'unit': 'Apt 4', 'city': 'Miami', 'state': 'FL', 'zip': '33101'}})returns'Jamal Walker\n400 Pine Ave, Apt 4\nMIAMI, FL 33101'
callshipping_label({'customer': {'first': 'GRACE', 'last': 'WALKER'}, 'address': {'street': '9 Oak Rd', 'city': 'denver', 'state': 'co', 'zip': '80202'}})returns'Grace Walker\n9 Oak Rd\nDENVER, CO 80202'

Loading your progress…

Print-ready shipping label — Python practice · Runtime