Welcome to Westonci.ca, the place where your questions are answered by a community of knowledgeable contributors. Join our platform to connect with experts ready to provide accurate answers to your questions in various fields. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.

8.19 LAB: 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), separated by a comma. That list is followed by a name, and your program should output the phone number associated with that name. Assume the search name is always in the list.
Ex: If the input is:
Joe,123-5432 Linda,983-4123 Frank,867-5309
Frank
the output is:
867-5309


Sagot :

Multiple values can be stored in a single variable by using lists.

Program:

allContacts = input()

contactName = input()

splitContact = allContacts.split(" ")

for i in range(len(splitContact)):

if(splitContact[i] == contactName):

print(splitContact[i+1])

What is Lists?

  • Multiple elements can be kept in a single variable by using lists.
  • One of the four built-in data types in Python for storing data collections is the list; the other three are the tuple, set, and dictionary, each of which has a unique purpose.
  • List items can have duplicate values and are ordered and editable.
  • The first item in a list has the index [0], the second item has the index [1], etc.
  • The list is modifiable, which means that after it has been generated, we can edit, add, and remove entries from it.
  • The len() method can be used to count the number of elements in a list
  • Lists can contain items with the same value since they are indexed

To learn  more about Lists refer to:

https://brainly.com/question/560095

#SPJ4