ContactBook program using Python


Source Code :

class ContactBook:

    def __init__(self):
        self . contactname = ""
        self . MobileNumber = ""

    def giveyourcontactdetials(self):
        self . contactname = input("Enter person name")
        self . MobileNumber = input("Enter the Mobile Number")

    def display(self):
        print("Contact Name     : " , self . contactname)
        print("Mobile Number   : " , self . MobileNumber)
        print("\n")
        
TheContactList = []

thechoice = 'y'

while (thechoice == 'y'):
    print(" 1.Add New Contact\n 2.Display Contacts")
    userresponse = int(input("Enter your choice"))

    if (userresponse == 1):
        contact = ContactBook()
        contact . giveyourcontactdetials()
        TheContactList . append(contact)

    elif (userresponse == 2):
        for value in TheContactList:
            value . display()

    else:
        print("please check your response")

    thechoice = input("press 'y' to continue")  





Output : 





***********************************************************************************

Post a Comment

0 Comments