Problem:
Creating a phone book with names and phone numbers. Taking Input from user to search names in the dictionary and display the numbers in the format name=number.
n = int(input().strip())
PhoneBook={}
for i in range(n):
name=input()
phoneNum=name.split()
PhoneBook[phoneNum[0]]= phoneNum[1]
while True:
try:
find = input().strip()
except EOFError as e:
break
if find not in PhoneBook.keys():
print("Not found")
elif find in PhoneBook.keys():
print(f'{find}={PhoneBook.get(find)}')
No comments:
Post a Comment