how to match list members in py3.x
On 25/11/2018 11.41, Richard Damon wrote:
> On 11/25/18 12:28 PM, Muhammad Rizwan wrote:
>> handle = open('file.txt')
>> newlist = list()
>> for line in handle:
>> linewords = line.split()
>> for word in linewords:
>> if word not in linewords:
>> print('new: ',newlist)
> The first thing I note in looking at this is that the second loop will
> run AFTER the first loop completes, not for each step of the loop,
> because you outdented the code.
> Also, you unconditionally add the word, and THEN check if it is in the list.
And the first thing that I note is that he checks to see if it is in
the list from which it came.
Michael F. Stemper
Economists have correctly predicted seven of the last three recessions.