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