Project to create a phone book, where is the mistake?!!
I try to do an exercise, the Requirements: Build a program that represents the phone book, so that it receives the phone number, and returns to us the name of the owner of the number. In the event that a number in the directory is sent, the name of the owner of the entered number will be printed, and in the event that a number that is not in the phone book is entered, the message will be printed: "Sorry, the number is not found" If the phone number is less than or more than 10 digits, or some other value (it contains letters, symbols, and logical values for example), the sentence will be printed: "This is invalid number"
My code is:
namephone = {'Amal':1111111111,
'Mohammed':2222222222,
'Khadijah':3333333333,
'Abdullah':4444444444,
'Rawan':5555555555,
'Faisal':6666666666,
}
namey = ''
def serch(h):
for x, y in namephone.items():
if y == h:
namey = x
continue
else:
namey = 'Sorry, the number is not found'
return namey
qustion =input("pleas inter number")
if qustion.isdigit() and len(qustion )== 10:
serch(qustion)
else:
print('This is invalid number')
print(namey)
If we enter a number from the numbers in the dictionary, it gives us an empty result!!!! e.x. if we enter '6666666666' what is in the dictionary we will get empty result
What is the rong?