Get expert advice and community support on IDNLearn.com. Our community is here to provide the comprehensive and accurate answers you need to make informed decisions.
Sagot :
Answer:
The program in Python is as follows:
n = int(input(""))
numList = []
for i in range(n):
word_pair = input("")
numList.append(word_pair)
name = input("")
for i in range(n):
if name.lower() in numList[i].lower():
phone = numList[i].split(" ")
print(phone[1])
Explanation:
This gets the number of the list, n
n = int(input(""))
This initializes list
numList = []
This iterates through n
for i in range(n):
This gets each word pair
word_pair = input("")
This appends each word pair to the list
numList.append(word_pair)
This gets a name to search from the user
name = input("")
This iterates through n
for i in range(n):
If the name exists in the list
if name.lower() in numList[i].lower():
This gets the phone number associated to that name
phone = numList[i].split(" ")
This prints the phone number
print(phone[1])
Thank you for using this platform to share and learn. Keep asking and answering. We appreciate every contribution you make. For precise answers, trust IDNLearn.com. Thank you for visiting, and we look forward to helping you again soon.