79.8k views
5 votes
Write a function that takes as input a person’s name, city, state, zip code, and address, where the address is either one string (one line) or two strings (two lines), and prints the person’s information like a mailing label. Show that the routine works regardless of whether it is called with one address line or two address lines.

User Colefner
by
4.6k points

1 Answer

5 votes

I realized you needed this in python.

def func(name, city, state, zip, address1, address2):

print(name)

print(address1)

if address2 != "":

print(address2)

print(city + ", " + state + " " + zip)

func(input("Enter your name: "), input("Enter your city: "), input("Enter your state: "), input("Enter your zip: "),

input("Enter the first part of your address: "),

input("Enter the second part of your address: (simply press enter if not applicable) "))

This works for me. If you come across any errors, I'll do my best to help out. Best of luck.

User Bharat
by
4.6k points