Print mailing lables
Here is a simple Python script that prints mailing labels:
class MailingLabel:
def __init__(self, name, address, city, state, zip):
self.name = name
self.address = address
self.city = city
self.state = state
self.zip = zip
def print_label(self):
print(f"{self.name}\n{self.address}\n{self.city}, {self.state} {self.zip}")
def main():
labels = []
while True:
name = input("Enter the name (or 'q' to quit): ")
if name.lower() == 'q':
break
address = input("Enter the address: ")
city = input("Enter the city: ")
state = input("Enter the state (2-letter abbreviation): ")
zip = input("Enter the zip code: ")
label = MailingLabel(name, address, city, state, zip)
labels.append(label)
for label in labels:
label.print_label()
if __name__ == "__main__":
main()
This script creates a MailingLabel
class that has attributes for the name, address, city, state, and zip code. The print_label
method prints the label in the format:
Name
Address
City, State Zip
The main
function asks the user to input the information for each label, and then prints out the labels. The user can quit by entering 'q' when prompted for the name.