This is probably too basic but let me ask anyway!
I'm looking for a way to get a field number that contains my match so that I can do more work based on the result.
I tried something like:
with open(filename) as f:
for line in f:
for field in range(-1, 0,-1): # Wrong --> How can I decrement starting from the last field backwards to the 1st field in each line of a file?
if pattern in field:
print("field# " + field + " shows:" + line.split(' ')[field])
Thanks in advance!
- Steve