Question: This is for a python class. The intent of this program is to manage a set of contacts. Each contact will have data associated with

This is for a python class.

The intent of this program is to manage a set of contacts. Each contact will have data associated with it:

  • Id number/integer
  • First Name string
  • Last Name string
  • Age number/integer
  • Phone Number string
  • Email string
  • Anything else youd like to add to make yours unique (can result in extra credit)
    • Gender character or string (m/f/o)
    • Twitter ID, Facebook Id, etc

You must allow the customer to do the following actions on the contact list:

  1. List all contacts
  2. Add contact
  3. Delete contact
  4. Edit contact
  5. Exit program

You should use classes for this assignment. This means you should have two classes:

  • Contact all the attributes/properties described above with appropriate constructor. Methods:
    1. Add (constructor - __init__(p_id, p_fname, p_lname, p_age, p_phone, p_email, p_gender)
    2. Edit
  • Contact List (contact_list) built on Python list (or creating one within the constructor), you should have methods:
    1. Add add a new contact to the list
    2. Edit edit a contact within the list
    3. Delete delete a contact from the list

This is what I have so far, However, I seem to be stuck on the MODIFY CONTACT MENU. I only have 2 options right now but whenever I try either of those options it just redisplays the MODIFY CONTACT MENU. It's like it's stuck in a loop and I'm not sure how to fix it.

This is for a python class. The intent of this program isto manage a set of contacts. Each contact will have data associatedwith it: Id number/integer First Name string Last Name string Age number/integer

1 2 3 def 4 5 6 7 class Contact: _init_(self, p_id, first_name, Last_name, age, phone, email, gender, height, weight): self.ID = p_id self.first_name = first_name self.last_name = last_name self.age = age self-phone = phone self-email = email self-gender = gender self-height = height self.weight = weight class Contactlist: def _init_(self, contact_list_name = 'none', date_created = 'Febuary 17, 2021', contact_list = []): self.contact_list_name = contact_list_name self.date_created = date_created self.contact_list = contact_list 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 def add_person(self): print("Let's add a new person ") self.first_name - input("What is their first name?:") self.last_name = input("What is their last name?:") self-age = int(input("What is their age?: ")) self-phone = int(input("What is their phone number?: ")) self.email = input("What is their email?:") self-gender = input("What is their gender?(Male/Female): ") self.height = int(input("What is their height?: ")) self.weight = int(input("What is their weight?: ")) 29 30 31 32 33 34 35 36 37 38 39 40 41 def modify_contact(self): contact_list = newlist modify_menu = (" MODIFY CONTACT MENU " "1: Change their first name " "2: Change their last name " "3: Change their age " "4: Change their phone number " "5: Change their email " "6: Change their gender " "7: Change their height " "8: Change their weight " "O: exit, back to main menu ") 42 43 44 45 46 47 48 49 50 51 52 command = while command != @: print(modify_menu) command = input('Choose an option: ') while command != '1' and command != '2' and command != '3' and command != '4' and command != '5' and command != '6' and command != '7' and command != '8': command = input('Choose an option: ') if command == 1: print(" CHANGE FIRST NAME') name input('Enter the first name you would like to change: ") new_name = input('Enter the new first name: ') item_removed = False for first in self.first_name: if(first.first_name == name): first.first_name = new_name item_removed = True if not item_removed: print("Name not found in contact list, nothing changed.') 54 55 56 57 58 59 60 61 62 63 64 65 66 elif command == 2: print(" CHANGE LAST NAME') name = input('Enter the name you would like to change : ') new_name = input('Enter the new name: ') item_removed = False for last in self.last_name: if(last.last_name == name): last.last_name = new_name item_removed = True if not item_removed: print("Name not found in contact list, nothing changed.') 67 68 69 70 71 72 73 74 75 76 77 elif command == 3: pass elif command == 4: pass elif command == 5: 12C elif command == 3: pass elif command == 4: pass elif command == 5: pass elif command == 6: pass elif command == 7: pass elif command == 8: pass 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 def print_menu(Contactlist): contact_list = newList menu = (' MAIN MENU ' 'a - Add person to contact list ' 'r Remove person from contact list ' 'c Change contact info ' 'd - Display contact list ' 'a Quit ') command while(command != 'q'): string="! print(menu) command input('Choose an option: ') while(command != 'a' and command != 'r' and command != 'c' and command != 'd' and command != 'q'): command input('Choose an option: ') if command == 'a': contact_list.add_person() if command == 'r': contact_list.remove_person() if command == 'c': contact_list.modify_contact() if command == 'd': contact_list.display_contacts() if name == "__main_": contact_list_name = str(input('What would you like your contact list to be called? ')) date_created = str(input('Enter the date it was created: ')) print() print('Contact List Name:', contact_list_name) print('Date created:', date_created) newList = Contactlist(contact_list_name, date_created) print_menu(newlist) 1 2 3 def 4 5 6 7 class Contact: _init_(self, p_id, first_name, Last_name, age, phone, email, gender, height, weight): self.ID = p_id self.first_name = first_name self.last_name = last_name self.age = age self-phone = phone self-email = email self-gender = gender self-height = height self.weight = weight class Contactlist: def _init_(self, contact_list_name = 'none', date_created = 'Febuary 17, 2021', contact_list = []): self.contact_list_name = contact_list_name self.date_created = date_created self.contact_list = contact_list 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 def add_person(self): print("Let's add a new person ") self.first_name - input("What is their first name?:") self.last_name = input("What is their last name?:") self-age = int(input("What is their age?: ")) self-phone = int(input("What is their phone number?: ")) self.email = input("What is their email?:") self-gender = input("What is their gender?(Male/Female): ") self.height = int(input("What is their height?: ")) self.weight = int(input("What is their weight?: ")) 29 30 31 32 33 34 35 36 37 38 39 40 41 def modify_contact(self): contact_list = newlist modify_menu = (" MODIFY CONTACT MENU " "1: Change their first name " "2: Change their last name " "3: Change their age " "4: Change their phone number " "5: Change their email " "6: Change their gender " "7: Change their height " "8: Change their weight " "O: exit, back to main menu ") 42 43 44 45 46 47 48 49 50 51 52 command = while command != @: print(modify_menu) command = input('Choose an option: ') while command != '1' and command != '2' and command != '3' and command != '4' and command != '5' and command != '6' and command != '7' and command != '8': command = input('Choose an option: ') if command == 1: print(" CHANGE FIRST NAME') name input('Enter the first name you would like to change: ") new_name = input('Enter the new first name: ') item_removed = False for first in self.first_name: if(first.first_name == name): first.first_name = new_name item_removed = True if not item_removed: print("Name not found in contact list, nothing changed.') 54 55 56 57 58 59 60 61 62 63 64 65 66 elif command == 2: print(" CHANGE LAST NAME') name = input('Enter the name you would like to change : ') new_name = input('Enter the new name: ') item_removed = False for last in self.last_name: if(last.last_name == name): last.last_name = new_name item_removed = True if not item_removed: print("Name not found in contact list, nothing changed.') 67 68 69 70 71 72 73 74 75 76 77 elif command == 3: pass elif command == 4: pass elif command == 5: 12C elif command == 3: pass elif command == 4: pass elif command == 5: pass elif command == 6: pass elif command == 7: pass elif command == 8: pass 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 def print_menu(Contactlist): contact_list = newList menu = (' MAIN MENU ' 'a - Add person to contact list ' 'r Remove person from contact list ' 'c Change contact info ' 'd - Display contact list ' 'a Quit ') command while(command != 'q'): string="! print(menu) command input('Choose an option: ') while(command != 'a' and command != 'r' and command != 'c' and command != 'd' and command != 'q'): command input('Choose an option: ') if command == 'a': contact_list.add_person() if command == 'r': contact_list.remove_person() if command == 'c': contact_list.modify_contact() if command == 'd': contact_list.display_contacts() if name == "__main_": contact_list_name = str(input('What would you like your contact list to be called? ')) date_created = str(input('Enter the date it was created: ')) print() print('Contact List Name:', contact_list_name) print('Date created:', date_created) newList = Contactlist(contact_list_name, date_created) print_menu(newlist)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!