["python","boolean"]
How do I get the opposite (negation) of a Boolean in Python?

For the following sample: def fuctionName(int, bool): if int in range(...): if bool == True: return False else: return True Is there any way to skip the second if-statement? Just to tell the computer to return the opposite of the boolean bool?
To negate a boolean, you can use the not operator: not bool Or in your case, the if/return blocks can be replaced by: return not bool Be sure to note the operator precedence rules, and the negated is and in operators: a is not b and a not in b.