#!/usr/bin/python3 import string sum = 0 with open("input") as fh: groups = fh.read().split("\n\n") for g in groups: g = g.strip() g_yes = set(string.ascii_lowercase) for p in g.split("\n"): p_yes = set(p) g_yes = g_yes & p_yes sum += len(g_yes) print(g.replace("\n", "."), g_yes, sum) print(sum)