Search code examples
python-2.7boolean-logicboolean-operations

Don't understand this Boolean operator logic


def odd(x):
    x % 2
    return x > 0

Why does my function return True for even numbers?


Solution

  • you need to change it to:

    x = x % 2
    

    to actually update the variable in line 2.