← Back to challenges

Flip the Boolean

PythonMediumlogiclanguage_fundamentalsconditionsvalidation

Instructions

Due to a programming concept known as truthiness, certain values can be evaluated to (i.e. take the place of) booleans. For example, 1 (or any number other than 0) is often equivalent to True, and 0 is often equivalent to False.

Create a function that returns the opposite of the given boolean, as a number.

Examples

flip_bool(True) ➞ 0

flip_bool(False) ➞ 1

flip_bool(1) ➞ 0

flip_bool(0) ➞ 1

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Check if All Values Are True