Question: Needs to pass All doc test is not printing out the values that are needed, i also need it to print like the doc test.
Needs to pass All doc test is not printing out the values that are needed, i also need it to print like the doc test. def filter_dict(filename, min, max): """ From the specified dictionary file containing 1 word per line, return a list of words whose lengths are within the user-specified bounds. So for instance, if the min is 3 and max is 7, then only words with length >= 3 and length <= 7 will be returned in the list. :param filename: the dictionary file containing 1 word per line :param min: the min length (inclusive) of words to return :param max: the max length (inclusive) of words to return
>>> filter_dict('small_dict.txt', 3, 5) ['acted', 'bios', 'coder', 'find', 'gore', 'knife', 'racer'] >>> filter_dict('small_dict.txt', 7, 10) ['debased', 'shameful'] """ accepted = {} #opening the file in read mode file = open(filename,"r") #looping over the file for line in file: #checking length of the line if (len(line) >= min) and (len(line) <= max): print(line)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
