Part #2: Phonebook class Design a Python class for a Phonebook. You class should
ID: 3824834 • Letter: P
Question
Part #2: Phonebook class
Design a Python class for a Phonebook. You class should have the following methods:
__init__ (self): creates an empty list to store names and numbers
Add(self, name, number): adds the name and number to the list
Display(self): displays the entire phonebook.
Find(self, name): finds and prints the number in the phonebook that is associated with the name
Add a main() method to the script that adds a couple phone entries and calls the display() and find() methods to see if they work.
Explanation / Answer
def __init__(self):
pass
def add(self,name, number):
self.name=name
self.numbers=number
def getName(self):
return self.name
def getNumber(self):
return self.number
def find(self, name):
a = raw_input("What is their First Name?")
return(self,name)
def display(self):
return display