I have some code with an if-statement in it, and one of the conditions is a boolean. However, CodeSkulptor says "Line 36: TypeError: unsupported operand type(s) for BitAnd: 'bool' and 'number'". Please help if you can. This is what that piece of code looks like. (I just changed all the variable names and what the if-statement executes)
thing1 = True
thing2 = 3
if thing2 == 3 & thing1:
print "hi"
You want to use logical and
(not the &
, which is a bitwise AND operator in Python):
if thing2 == 3 and thing1:
print "hi"
Because you have used &
, the error has popped up, saying:
TypeError: unsupported operand type(s) for BitAnd: 'bool' and 'number'
^^^^^^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With