← Back to challenges

Fix the Error: Check Whether a Given Number Is Odd

PythonMediumbugsnumbersvalidation

Instructions

Éowyn has written the function is_odd() to check if a given number is odd or not. Unfortunately, the function does not return the correct result for all the inputs. Help her fix the error.

def is_odd(num):
  return num % 1 == 1 or 2

Examples

is_odd(-5) ➞ True

is_odd(25) ➞ True

is_odd(0) ➞ False

Notes

All the inputs will only be integers.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Convert All List Items to String