← Back to challenges

No Conditionals?

PythonMediumcontrol_flowlogic

Instructions

Write a function that returns 0 if the input is 1, and returns 1 if the input is 0.

Examples

flip(1) ➞ 0

flip(0) ➞ 1

Notes

Try completing this challenge without using any:

  • Conditionals
  • Ternary operators
  • Negations
  • Bit operators
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Fix Basic Calculator