from collections import defaultdict
results = [
(“pass”, “Taro”),
(“pass”, “Jiro”),
(“fail”, “Saburo”),
(“pass”, “Shiro”)]
stats = defaultdict(list)
for result, name in results:
stats[result].append(name)
print(dict(stats))
from collections import defaultdict
results = [
(“pass”, “Taro”),
(“pass”, “Jiro”),
(“fail”, “Saburo”),
(“pass”, “Shiro”)]
stats = defaultdict(list)
for result, name in results:
stats[result].append(name)
print(dict(stats))