Computer Science, asked by masattarsunnyoyp7ov, 10 months ago

Write a program in Python to input ‘n’ names and phone numbers and store in

a python dictionary. The program should ask the user to input any name and

then print the phone number of that particular name .An error message

should be displayed if the name does not exist.

Store the data in a dictionary as shown in the example below:


{'Amit': '123456789', 'Harsh': '345678912', 'Shikha': '234567891', 'Vibha':

'987654321'}

Answers

Answered by zackneil11
3

Answer:

dictcus={}

def addCust(id,name,ph):

   dictcus[id]=[name,ph]

   print(dictcus)

print("Welcome")

while(1):

   choice=input("Enter 1 ")

   if(choice=="1"): #Add Details

       id=input("Enter ID: ")

       name=input("Enter name: ")

       ph=input("Enter ph_num: ")

       addCust(id,name,ph)

       print("Details added successfully")

   else:

       exit()

Explanation:

May be this will be helpful... thankyou!!

Similar questions