← Back to challenges

Both Zero, Negative or Positive

PythonMediumnumbersmathvalidationconditions

Instructions

Write a function that returns True if both numbers are:

  • Smaller than 0, OR ...
  • Greater than 0, OR ...
  • Exactly 0

Otherwise, return False.

Examples

both(6, 2) ➞ True

both(0, 0) ➞ True

both(-1, 2) ➞ False

both(0, 2) ➞ False

Notes

Inputs will always be two numbers.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Adding Numbers in a String