You are on page 1of 1

PRACTICAL-07

Ques. Write a user-defined function findname(name) where name is an


argument in pyhton to delete phone number from a dictionary phonebook on
the basis of the name , where name is the key .
#define the function
phonebook={'Neha':9876215590,'Rohan':9899234598,'Akash':9773512190}

def findname(name):

k=phonebook.keys()

if name in k :

del phonebook[name]

else :

print("Name not found")

print("Phonebook Information")

print("Name",'\t',"Phone Number")

for i in phonebook.keys() :

print(i,'\t',phonebook[i])

findname('Rohan')

OUTPUT
Phonebook Information

Name Phone Number

Neha 9876215590

Akash 9773512190

You might also like