TypeError: 'bool' object is not callable - python
Question: I'm trying to implement a simple maths game where the user is given random
numbers and operators then they have to work out the answer, I found sources
on the internet that suggested using the operator module, which is why i used
it, if there is a more efficient/ easier way of achieving this I am very open
for interpretation.

Essentially i am trying to remove this horrible `<built-in function add>` and
swap it to be more user friendly by saying '+' or 'add', something along those
lines but i keep getting the error 'TypeError: 'bool' object is not callable -
python', i really dont know what this means, i am new to python and am very
confused.

    
    
     from operator import add, sub, mul, floordiv
    
     operators = (add == str("add"), sub == str("subtract"), mul == str("multiply"), floordiv == str("divide"))
     operator = random.choice(operators)
     answer = operator(number1, number2)
     question = print("What is ", number1, operator, number2, "?")
    


Answer: What you get as a result of the first line is

    
    
    operators = (False, False, False, False, False)
    

or something in those lines.

Then you are trying to call a boolean that gets you the exception you have.

`add == str("add")` will evaluate to `False`, since you're trying to compare a
function to a string.

I'm assuming you are trying to implement a simple math game, hence instead of
using `operator`, which are in fact math operation functions, you can just use
a simple dictonary:

    
    
    operators = { 'add': add, 'substract': sub, 'multiply': mul }
    answer = operators[random.choice(operators.keys())](number1, number2)
    

