numberOfSectionsInTableView
答案 0 :(得分:0)
在函数dict_count中,您从未创建过filtered_text变量,然后您想要使用它。
您必须先创建变量,然后才能使用:
filtered_text = filter_file(files)
完整代码:
def dict_count(files):
""" for loop to return dict with word count and length keys """
lengths = {}
filtered_text = filter_file(files)
for word in filtered_text: # And this also
length = len(word)
if length not in lengths:
lengths[length] = 0
lengths[length] += 1
for length, counter in lengths.item():
return "Words of length %d: %d" % (length, counter)