def TruthTable(text):
    table = {}
for line in text.splitlines():
    line = line.strip()
if line:
    inputs, output = line.split()
table[tuple(bool(int(x)) for x in inputs)] = bool(int(output))
return lambda *inputs: table[inputs]
How to write If statements for all 2^N boolean conditions (python)