Hey all,
I'm a beginner.
When i feed a list of lines into this for statement, i have trouble getting the output into a set for use outside of the for statement.
ListofWordsinLines = {}
words = []
for line in ListOfLines:
words = line.split()
ListofWordsinLines = set(words)
if i print (ListofWordsinLines) in the loop i get the desired set.
As soon as i try to use it outside of the loop i only get the last line in the set. So if it was a block of text 10 lines long i only get the bottom line.
I know this is happening because my for line in WordFileRead: is addressing each line sequentially but my experience/knowledge doesn't let me figure out what to do next.
Thanks in advance!