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