0
[ANSWERED] Task using boolean types
Let's say I have a string str that contains a logical formula. If i know the formula I just do print((True or False) and True) But if I have only a string that contains the formula like str = "(True or False) and True)" How to convert a string to a command, a boolean variable? bool() wont work, it is sth different.
1 Answer
+ 9
You could use eval() for that:
str = "(True or False) and True)"
print(eval(str))
>>>
True