Question: lass Contact: contacts _ list = [ ] def _ _ init _ _ ( self , first _ name, last _ name, email )
lass Contact:
contactslist
def initself firstname, lastname, email:
self.firstname firstname
self.lastname lastname
self.email email
def displaycontactself:
return fselffirstnameselflastname: selfemail
if lencontactslist:
printfirstname,lastname:email"
for contacts in contacts:
printselfdisplaycontact
else:
printNo class have been added yet."
def addcontactself:
try:
firstname inputEnter first name:
lastname inputEnter Last name:
email inputinputEnter email:
# instantiate contact, add to dictionary
contactslist.appendselffirstname, lastname, email #append Contact
except ValueError:
printSome data entered is invalid, no data accepted.
def main:
contactslist
while True:
print
menu options. choose
display all contacts
create new contact
Exit
opt inputEnter your chioce,
if opt : # display all contact
displaycontactcontactslist
elif opt : # add a contact
contact addcontactcontactslist
elif opt : # exit program
printGoodbye
print
else:
printInvalid entry, please reenter your choice"
print
main can you show me what is going wrong
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
