Q. Write code to create a python dictionary add three name and their phone in the dictionary after getting input from user. the names should act as keys and phones as their values. then ask the user a name and print its corresponding phone.




Answer = 

dic = {}

for i in range (3):
    name  = input ("Enter the name :- ")
    phone = input ("Enter the Phone number :- ")
    dic [ name ] =  phone

while True :
    a = input("Enter the name from the dictionary (For exit enter 'q'):- " )
    if a == "q"or a== "Q":
        break
    else :
        print (dic[a])



Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post