![]() ![]() lower() if change="y": new_name=input("Change name to:") lower() if change1 ="y": new_phone=input("Change phone number to:") phone=new_phone print("The changes have been made!") bEntry=True else: print ("This name was not found, please try again.") elif val="2": email=input("What e-mail do you want to search? ") for line in name: if semail in line: i=name.index(semail) if i>O: new_email=input("Change E-mail to:") email=new_email change=input("Do you want to update the name? (Y/N) ") change=change. Quit\n") if choice = "1": add_entry(name, email, phone) elif choice = "7": 41 42Ĥ3 44 45 46 47 48 update_entry(name, email,phone) elif choice = "3": || delete_entry(name, email, phone) elif choice ="4": | search_entry(name, email, phone) elif choices"5": file=open("AddressBook.txt","r") for 1 in (name, email, phone): file.write("\t\t\t".join(map(str, 1)) "\n") else: print("That is not a valid entry, please try again./n") 49 def main(): file = open("AddressBook.txt","r") q = input("Would you like to display a current list of contacts? (Y/N)") q = q.lower) if q = "y": contents=file.read() print("\nName:\t\tE-Mail:\t\t\t\tPhone Number: \n") print(contents) main_menu(file) else: print("Thank you for testing my program!") 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 def add_entry(name, email, phone): new_name=input("Enter a name to add :") new_email=input("Enter a email to add:") new_phone=input("Enter a phone number to add :") name.append(new_name) email.append(new_email) phone.append(new_phone) print ( new_name new_email ", and " new_phone " were added!") return name, email, phone def update_entry(name, email, phone): bEntry=false i=0 val=None while (bEntry=False):Ĩ5 86 87 print("Search for a contact to update:") val=input("How would you like to search?\n\t1.Name\n\t2.E-mail\n\t3.Phone Number") if val="1" or val="2" or val="3": if val="1": sname=input("What name do you want to search?:") for line in name: if sname in line: i=name.index(sname) if i>o: new_name=input("Change name to:") name=new_name change=input("Do you want to update the e-mail?(Y/N) ") change=change. splito 18 19 e = line.stripo line_list = e.split() p = line.splito line 11st = p.splito #print(n)- name.append(line_list) email.append(line_list) phone.append(line_list) f.close() 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 print(name) print(email) print(phone) #name - #email : info #phone - info while (choice !="5"): choice = input("what would you like to do? Enter a number 1-5:\n\ti. Quit 4ġ 5 def main menu (f): # This initiates the address books and allows users to select which feature to use choice=None size = 180 7 8 9 10 11 12 13 14 15 16 17 file=open("AddressBook.txt","r") name = email - () phone = 1 for line in f: n = line.stripo line_list = n. ![]() Phone number 1 Which name do you want to search? G Petro Do you want to update contact name? (Y/N)y Change name to: Sarah Petro Do you want to update email address? (Y/N)n Do you want to update phone number? (Y/N)n Do you want to add, update, delete, or search another contact? (Y/N)y What would you like to do? Enter a number 1-5: 1. ![]() Quit 2 Search for a contact to update: How would you like to search? 1. Would you like to display a current list of contacts? (Y/N) y NAME: E-MAIL: PHONE NUMBER: John Johnson Sasha Petro Susan Davies G Petro (240)123-4567 (443)990-0987 (978) 677-0765 (443) 990-0123 What would you like to do? Enter a number 1-5: 1. ![]()
0 Comments
Leave a Reply. |