#!/usr/bin/env python3 import pprint person = "Sarah Miller" # Dictionary to store people people = dict() fd = open('people.csv', 'r') contents = fd.readlines() for line in contents: line = line.strip() line = line.split(',') # Check length of the line # The first item in line is the name name = line[0] # The second item is their email email = line[1] people[name] = email pprint.pprint(people) fd.close() # Get this from commandline args fd = open('lookup.txt', 'r') for line in fd.readlines(): name = line.strip() print(people.get(name, 'User not found.')) fd.close() # Commandline arguments : file1 file2 # File1: csv file containing people (use people.csv as a sample) # File2: file containing list of people to lookup (use lookup.txt as a sample) # Read records from people.csv into a dictionary # You will probably want to split the lines by a comma # You won't need to use the csv library # The key should be their name and the value should be their email # Print the entire dictionary using pretty print # Read names from lookup.txt (one name per line) # Print the email of the associated of the person # If the user is not in the dictionary print 'User not found.'