The problem is an error in the argument your passing to set
:
set1 = set([words1])
is defining a list of one item - that contains a list of words.
- eg:
[["a", "b", "c"]]
...
- when I guess you would want only
["a", "b", "c"]
.
remove the []
and do set1 = set(words1)