Final answer:
To manage a contact list in a program, split name and phone number pairs, store them in a dictionary, and then retrieve the phone number by searching the name in the dictionary.
Step-by-step explanation:
To write a program that manages a contact list, you will need to store pairs of names and phone numbers, and provide a way to retrieve a phone number by name. First, the program should collect input where each entry consists of a name and a phone number, separated by a comma. Then the program should accept a name and return the associated phone number. Here is a step-by-step guide illustrating the concept:
- Collect contact entries from the user.
- Split each entry on the comma to separate the name and phone number.
- Store the split results in a dictionary with names as keys and phone numbers as values.
- Accept a name from the user to search the contact list.
- Output the phone number that corresponds to the given name.
An example of using this program would be if the input is 'Joe,123-5432 Linda,983-4123 Frank,867-5309' followed by 'Frank', the output should be '867-5309'. This requires splitting the input string into a dictionary where 'Frank' is a key, and '867-5309' is the associated value.