Welcome to Westonci.ca, the Q&A platform where your questions are met with detailed answers from experienced experts. Explore thousands of questions and answers from a knowledgeable community of experts ready to help you find solutions. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
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])
We hope our answers were useful. Return anytime for more information and answers to any other questions you have. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Westonci.ca is committed to providing accurate answers. Come back soon for more trustworthy information.