# Report who is the Congressional Representative for a
# district.
# Example of a program written with functions

# Reads the input file and puts relevant data into a list
def readRepFile():
    repList = [] # start with the empty list
    
    repFile = open("reps.txt","r")

    # skip 3 lines
    for i in range(0,3):
        repFile.readline()

    # picks up on 4th line of file
    for line in repFile:
        words = line.split("\t") # split at tab characters
        repName = words[1] # the name is in position 1
        repList.append(repName) # put it into the list

    repFile.close() # close the file when done

    return repList  # the list becomes the output of the function

# stub for function that gets a district number from the user
# should be an integer between 1 and 53 (including 1 and 53)
def getDistrict():
    return 3

# function that gets a district number from the user and then
# reports the representative for that district
# Does it 5 times
def reportRep(repList):
    
    for i in range(0,5):
        dist = getDistrict() # dist is int, 1<=dist<=53
        rep = repList[dist-1] # list has positions 0 ... 52
        print("The representative in district",dist,"is",rep)

    return


def main():
    # read file and put relevant data in list
    repList = readRepFile()

    # answer questions based on list
    reportRep(repList)

# The only line outside a function definition!!!
# Follow this rule!!!
# PS from...import... lines should also be outside function definitions,
# at the top of the file
main()
