hamming_sets = {(lambda s: s[0] + s[1]): set(), (lambda s: s[0] + s[2]):
    set(), (lambda s: s[0] + s[3]): set(), (lambda s: s[1] + s[2]): set(),
    (lambda s: s[1] + s[3]): set(), (lambda s: s[2] + s[3]): set()}
for func, set_ in list(hamming_sets.items()):
    for ll in l:
        set_.add(func(ll))
total_count = 0
for line in f:
    line = line.strip()
if any(func(line) in set_ for func, set_ in list(hamming_sets.items())):
    total_count += 1
iterating through a list in python