Nov-17-2020, 11:33 PM
(Nov-17-2020, 08:53 PM)tester_V Wrote: They look the same to me but apparently, they are not .
it is still confusing.
These snippets of code are anything but same.
First one reads:
for every item in list: for every line in file
This means that for every item in list you go through all lines of file. If file is long and list is short this is not very optimal algorithm.
Second one reads:
for every line in file: is there any item from list in lineThis means that you go through file line by line and for every line check whether any item list is present.
any()
has short circuit feature i.e. it stops after first True.I don't know whether it is a problem or not, but if line is 'computer network' then current code finds 'two' from that line.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.