

def ReadFile(F):
    # This returns a list with the numeric values of file F,
    # which must already be open.
    list = []
    for line in F:
        stringnums = line.split()        
        list.append([int(stringnums[0]), int(stringnums[1])] )
    return list

def Average(L, i):
    # returns the average of entry i of list L
    sum = 0.0
    for entry in L:
        sum += entry[i]
    if len(L) > 0:
        return sum/len(L)
    else:
        return 0.0

def main():
    try:
        F = open("data2.txt", "r")
        L = ReadFile(F)
    except:
        L = []
    print "The averages are %.2f and %.2f" % (Average(L, 0), Average(L, 1) )
    print L
main()
    
