contacts={} print("\t \t Welcome to the Contact Book \t \t \n") run=True while run: print("Choose your option from below: \n 1.ADD CONTACT \t 2.SEARCH CONTACT \t 3.DELETE CONTACT \t 4. ALL CONTACTS \n") choice=input("Enter the option/number you want to perform: ") #ADD if choice.upper() in ["1", "ADD CONTACT", "ADD"]: print("\n \t \t ******* ADDING CONTACTS ******* \t \t \n") n1=int(input("ENTER HOW MANY CONTACTS YOU WOULD LIKE TO ADD IN THE CONTACT BOOK: ")) for i in range(n1): contact_name = input("\n ENTER THE CONTACT'S NAME: ") contact_num = int(input("ENTER THE CONTACT'S NUMBER: ")) contacts.setdefault(contact_name.title(), contact_num) print("\n \t \t SUCESSFULLY ADDED THE CONTACT!! ") #SEARCH elif choice.upper() in ["2", "SEARCH CONTACT", "SEARCH"]: print("\t \t ****** SEARCHING CONTACTS ****** \t \t \n") search_name=input("ENTER THE NAME YOU WANT TO FIND IN THE CONTACT BOOK: ").title() if search_name in contacts: print(f"CONTACT NAME IS AVALIABLE: \t {search_name} - {contacts[search_name]}") else: print("THE NAME WAS NOT AVALIABLE IN THE CONTACT BOOK ") #DELETE elif choice.upper() in ["3", "DELETE CONTACT", "DELETE"]: print("\n \t \t ****** DELETING CONTACTS ****** \t \t \n ") print(contacts) delete_name=input("ENTER THE NAME YOU WANT TO DELETE IN THE CONTACT BOOK: ").title() if delete_name in contacts: print(f"\n THE CONTACT WITH {delete_name},{contacts.pop(delete_name)} IS DELETED!!") else: print("THE NAME WAS NOT AVALIABLE IN THE CONTACT BOOK") #DISPLAY ALL elif choice.upper() in ["4","ALL CONTACT", "ALL", "DISPLAY ALL","DISPLAY","SHOW ALL"]: print("\n \t \t ****** ALL CONTACTS DISPLAY ****** \t \t \n ") print(contacts) print("\n") for i in contacts: print(f"{i} - {contacts.get(i)}") #INVALID else: print("Not Valid Option") #TO CHECK IF THE USER WANTS TO PERFORM THE TASK AGAIN while run: exit = input("WOULD YOU LIKE TO DO ANY OTHER OPERATIONS IN THE CONTACT BOOK *y/n*: ") if exit.lower() in ["yes", "y"]: run=True break elif exit.lower() in ["no","n","exit"]: print("Thank you for using this Contact Book!! ") run=False else: print("It is a invalid Input\nPlease use this format (Yes/No) ") run=True