In Similarities, I'm told that my functions in helpers.py (lines, sentences, and substrings) should return lists. However, when I try testing my functions, I receive an error telling me that "object 'list' does not have attribute 'replace'." I am directed to an error in compare, where main takes the list I returned and then takes the individual strings in a variable called "match".
When I test the outputs of my function, it looks like I return the list correctly. However, compare seems to put the entire list into "match", instead of just one string at a time.
Here is my code for lines:
def lines(a, b): """Return lines in both a and b""" alist = a.splitlines() blist = b.splitlines() results = list(set(alist) & set(blist)) print(results) return [results]
And here is the relevant part of compare:
# Compare files if args["lines"]: matches = lines(file1, file2) elif args["sentences"]: matches = sentences(file1, file2) elif args["substrings"]: matches = substrings(file1, file2, args["substrings"]) # Output matches, sorted from longest to shortest, with line endings escaped for match in sorted(matches, key=len, reverse=True): print(match.replace("\n", "\\n").replace("\r", "\\r"))