宿題の課題では、コメントを要件として使用して、この関数の本体を作成する必要があります。コメントで言及されている他の機能は私に提供されています:
def eventfreq(year,month):
'''
Read DOT1000.txt and return a list of (d,ct)
pairs, where d is a date object of the form
datetime.date(A,B,C)
having A equal to the year argument and
B equal to the month argument to eventfreq(year,month).
The ct part of each pair is the number of records
that had a date equal to datetime.date(A,B,C).
One more requirement: sort the returned list
in increasing order by date (the sorted function will
do this for you)
Use fieldict("DOT1000.txt") to get the dictionary
of tuples used for building the list of pairs
that eventfreq(year,month) will return.
'''
これが私の努力です:
def eventfreq(year, month):
N=fieldict('DOT1000.txt')[line][1]
L = [] # empty List for accumulation
for line in N: # data file is standard input
st = N[1] # get datetime.date
(L[st] = L.get(st,0) + 1)