import sys
filename = '/u1/class/cs151/HW9/people.csv'
fIn = open(filename)
all = fIn.read()
lines = all.split('\n')
#print(lines)
#sys.exit()
names = []
emails = []
for item in lines:
    data = item.split(',')
    if len(data) < 2: continue
    name = data[0]
    names.append(name)
    email = data[1]
    emails.append(email)
#print(names)
#print(emails)
#sys.exit()
print('Looking up Daniel Davis')
lookup_name = 'Daniel Daviss'
if lookup_name in names:
    i = names.index(lookup_name)
    print(emails[i])
else:
    print('Not found')
# Note -
#  In the loop we built two lists names and emails
#  We could have instead built a dictionary with name as key and email as value
#  Things we would have needed -
#    before loop: D = {}
#    in the loop: D[name] = email
#  (But should also check for duplicates)