Created
October 1, 2021 07:18
-
-
Save umitkacar/5548d904822745f2b3eddb7dfbb14459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Address: | |
def __init__(self, street, city, state, zipcode, street2=''): | |
self.street = street | |
self.street2 = street2 | |
self.city = city | |
self.state = state | |
self.zipcode = zipcode | |
def __str__(self): | |
lines = [self.street] | |
if self.street2: | |
lines.append(self.street2) | |
lines.append(f'{self.city}, {self.state} {self.zipcode}') | |
return '\n'.join(lines) | |
from contacts import Address | |
address = Address('55 Main St.', 'Concord', 'NH', '03301') | |
print(address) | |
55 Main St. | |
Concord, NH 03301 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment