Contact list A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes in word pairs that consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Ex: If the input is: Joe 123-5432 Linda 983-4123 Frank 867-5309 Frank the output is: 867-5309 ACTIVITY 10.17.1: LAB: Contact list 0/10 main.py Load default template... 1'Type your code here.'""

Respuesta :

Answer:

Explanation:

s = input()

name = input()

splits = s.split(" ")

i = 0

for i in range(len(splits)):

   if(splits[i] == name):

       break

print(splits[i+1])

Output:

Joe 123-5432 Linda 983-4123 Frank 867-5309

Frank 867-5309

Process finished with exit code 0

The program is an illustration of lists.

Lists are used to hold multiple values, in one variable.

The program in Python, where comments are used to explain each line is as follows:

#This gets input for all contacts

allContacts = input()

#This gets a contact name from the user

contactName = input()

#This splits the contact by space

splitContact = allContacts.split(" ")

#This iterates through the split contacts

for i in range(len(splitContact)):

   #If the current element of the list is the same as the input for contactName

   if(splitContact[i] == contactName):

       #The loop is forcefully exited

       break

#This prints the phone number

print(splitContact[i+1])

At the end of the program, the corresponding phone number is printed, if the contact name exists.

Read more about similar programs at:

https://brainly.com/question/14915340