from collections import defaultdict
d1 = {1: 2, 3: 4}
d2 = {1: 6, 3: 7}
dd = defaultdict(list)
for d in (d1, d2): # you can list as many input dicts as you want here
for key, value in d.items():
dd[key].append(value)
print(dd)
import string
for name in ["lloyd", "alice", "tyler"]:
name = {"name": string.capitalize(name), "homework": [], "quizzes": [], "tests": []}
d1 = {'k1': 1, 'k2': 2}
d2 = {'k1': 100, 'k3': 3, 'k4': 4}
d3 = {'k5': 5, 'k6': 6}
d = d1 | d2 | d3
print(d)
# {'k1': 100, 'k2': 2, 'k3': 3, 'k4': 4, 'k5': 5, 'k6': 6}