Methods For Our Madness :)


Methods For Our Madness

By now, our address book implementation is beginning to take shape.  You have created a Contact class and an AddressBook class, whose main property is our contactlist list.  We have also begun to implement methods, including addContact and importFromCSV. Before moving forward, please make sure those functions are working properly.

Today, we are going to implement a couple more methods in our AddressBook class. For this phase of development, you will need to code two new methods, bubbleSort() and printContactList().


Your sort method should implement a bubble sort, which sorts the address book by your contacts’ last names.  (Additionally, if two contacts have the same last name, it should put them in the right order as well, but save that for later.)


This method should print a list of all the contacts by looping through contactlist[].  For now, just include last name, first name, cell phone, and email in the output.

After implementing the functions above as part of the AddressBook class, please use the following main program to test your code.

# *****************************************************
# Main Program
# *****************************************************

# Create a contact
mycontact = Contact("George","Washington", "Geo", "555-1234", "234-1600",
	"", "PutPhotoHere", "1600 Pennsylvania Ave NW", "Washington",
	"D.C.", "20500")

print "The first President was " + str(mycontact.firstname) + " " + str(mycontact.lastname) + "."
print "His email is " + str( + "."

# Blank line
print ""

# Create an AddressBook object
myAddressBook = AddressBook('MyAddressBook')

# Add mycontact to AddressBook

# Load Contacts from CSV file

print ""

# Sort by last name

# Print address list

Here is an abbreviated sample of the output, which of course should include the 500 contacts sorted in alphabetical order.

The first President was George Washington.
His email is

500 contacts added to the AddressBook.

Abdallah Johnetta 919-225-9345
Acey Geoffrey 847-222-1734


Wolfgramm Irma 973-545-7355
Wolny Lavonna 22102 703-892-2914
Worlds Lorrine 33614 813-863-6467
Wrinkles Nana 10553 914-796-3775
Yaw Audry 813-797-4816
Yglesias Maurine 53214 414-573-7719
Yori Shawnda 407-538-5106
Yum Dierdre 215-325-3042
Zagen Serina 260-273-3725
Zane Sheridan 951-645-3605
Zepp Vincenza 619-603-5125
Zurcher Jerry 321-518-5938

Once your code is functioning properly, please copy your output to an email and send it to Then, use this submission link to submit your python program as usual.