I'm wondering how, in Python, I could convert strings like:
- "(True & False) | True"
- "((False | False) & (True | False)) & (False | True)"
To a boolean answer:
- True
- False
The bool() function doesn't seem to work.
Thanks,
I'm wondering how, in Python, I could convert strings like:
To a boolean answer:
The bool() function doesn't seem to work.
Thanks,
You can simply eval
these expressions as they are valid Python
>>> eval("(True & False) | True")
True
>>> eval("((False | False) & (True | False)) & (False | True)")
False