Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solution: compare rows

import sys
if len(sys.argv) != 3:
    exit(f"Usage: {sys.argv[0]} FILE FILE")

file_a, file_b = sys.argv[1:]

def compare(row_a, row_b):
    a = row_a.find(' ')
    b = row_b.find(' ')
    return a < b

with open(file_a) as fh_a, open(file_b) as fh_b:
    results = map(compare, fh_a, fh_b)
    print(results)

    for res in results:
        print(res)
<map object at 0x7f0858d3f8d0>
56
[False, True, False, True, True]
128