this is what i have so far but something ia wrong with my delete contact and modify contact functions and im not sure what is wrong. please help. thank you
will manage an individual's address book. The program should allow a user to add new contacts, print the entire address book, search for a contact, modify the information about a specific contact, delete a contact, and exit the program. These features should work as follows: . Display the menu to the user that contains all the above . Get input from the user. Note: Remember to perform input . Add new contact - For this option, get the name, address, options. Use a function for this option. (5 points) validation (5 points) phone number, and email address from the user. Write/Add them to a file contacts.txt. Note: Make sure to use exception handling when opening the file for read/write purposes. Write out the file such that all the information about an individual is on separate lines. For example, the name "Mickey" and address "DisneyLand" should be on separate lines rather than on the same line. (1o points) . Print the Address Book - For this option, print all the contents of the address book. (5 points) . Search for a contact - For this option, ask the user for the name of the contact who they are looking for. Based on the name, look for that individual in the file one line at a time and, if they are found, display all the information for that individual. If the individual is not found, then display a message to the user saying "There is no contact with that name in your address book." (10 points) . Delete a contact For this option, ask the user for the name of the contact who they want to delete from the addressbook. The first step is to find that individual in the file. If the individual exists in that file, then create a new file copy all the contents before that individual and after that individual into that new file. Then write the entire to a 'new file called contacts.txt. (1o points) . Exit For this option, ask the user if they want to continue (y). If they would like to continue, then display the menu and get input from the user. If not, exit the program. Note Make sure to include input validation for y. (5 points) 6 def search_contact): file open("contacts.txt","r" 8 name input("Enter the name that you want to search: ") 9 flag 0 0 for line in file: record = une. split(",") if recordte]. lower)name.Lower): 2 flag-1 print("Record found" print (len(record)) print("Name : "record [e]+" \tEmail: 34 35 "record[1]+"\tPhone: record [2]+"\tAddress: "record [3]) 36 37 38 39 40 41 def delete contact): 42 43 nane input ("Enter name of the contact you want to delete: " if flag 8: print("Contact not found") 37 file open("contacts.txt"." flag data"" for line in filer 45 46 47 48 49 50 51 52 record line.split(".") if recordle]. lower) name. lower): continue else: datas recordte]," recordl1,"+recordt2],"+record(3]+"n" file.close( printi txception occurea elif choice 2: try: print_contact) print("Exception occured") except: elif choice 3: try: search_contact) print("Exception occured") except: elif choice4: try: delete contact) print("Exception occured") except: elif choice 5: try: modify_contact) except: print("Exception occured") elif choice-6: repeat- input ("Do you want to continue(y)7") if repeat"y" continue else: breal else: print ("Invalid choice")