I am working on the similarities helpers.py.
On checking check50, I found that the generator below does not work as intended, where input is ('This is one. This is two. This is three. This is two. This is one.' and 'This is three. This is two. This is four. This is five.'... ), which the generator does not exclude the line (Expected 2 matches, not 3), even though I have specified 'line not in returnlist'.
returnlist = [line for line in alist if (line in blist and line not in returnlist)]
after then I change it back to a standard for loop and it works perfectly.
for line in alist:
if (line in blist) and (line not in returnlist):
returnlist.append(line)
so my question is, what makes the difference? I suspect that the generator creates all the answers before pushing to the returnlist, such that "line not in returnList" is simply checking an empty list from start to end. Thanks!