x = {a:None for a in l} x = {b:c for c, b in l if c}