Is this address complete enough to ship
The checkout refuses street-level addresses without a door number. A record has the street name and a number field that may be empty.
- A street that is empty or whitespace is invalid regardless of the number.
- A number of zero or less also makes the address invalid.
- Both present means it is valid.
address_valid(street: string, door_number: int) → bool
Where you start
def address_valid(street: str, door_number: int) -> bool:
Worked examples
| Call | Result |
|---|---|
address_valid("Bagdat Cad no 12", 12) | True |
address_valid(" ", 5) | False |
address_valid("Kumsal Sok", 0) | False |
address_valid("", 12) | False |
Hint
Trim the street, then check the number.
Reference solution in Python
def address_valid(street: str, door_number: int) -> bool:
return bool(street.strip()) and door_number > 0