How to Create Telephone Directory in Python

Telephone Directory is a Python application that keeps names and email addresses in a dictionary as key-value pairs. The program should display a menu that lets the user look up a person's email address, add a new name and email address, change an existing email address, and delete an existing name and email address. The program should pickle the dictionary and save it to a file when the user exits the program. Each time the program starts, it should retrieve the dictionary from the file and unpickle it.

import pickle
try:
 contact=pickle.load(open("save.p", "rb+"))
except IOError:
 contact={}
 pass
def pick():
 pickle.dump(contact, open("save.p", "wb")) 
def store():
 global contact 
 name=input("Enter name:")
 phone=input("Enter Phone:")
  if name in contact: 
 print("Contact Already exists !\n") 
 else: 


 

 

 

 

 

 

 

Continue Reading...


Learn Python 

Comments