Skip to content

Instantly share code, notes, and snippets.

@umitkacar
Created October 1, 2021 07:18
Show Gist options
  • Save umitkacar/5548d904822745f2b3eddb7dfbb14459 to your computer and use it in GitHub Desktop.
Save umitkacar/5548d904822745f2b3eddb7dfbb14459 to your computer and use it in GitHub Desktop.
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