Jan-09-2020, 11:09 AM
I suggest to use different style for opening files (using 'with'). In order to verify processing all rows one can use enumerate and printing out:
Code will output:
with open('for_net.txt', 'r') as f: for i, row in enumerate(f, start=1): if 'net' in row.lower(): print(f'Row #{i} contains "net": {row.strip()}') else: print(f'Row #{i} does not contain "net"')if 'for_net.txt' contains following four rows:
Quote:This is not
but here is net
and not
and net
Code will output:
Output:Row #1 does not contain "net"
Row #2 contains "net": but here is net
Row #3 does not contain "net"
Row #4 contains "net": and net
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.