Python Python Basics (2015) Number Game App Even or Odd

not sure what I'm missing (again)

so I've:

1) made the function even_odd with number as it's argument 2) defined number so the value would equal either 0 (even) or 1 (odd) 3) created an if loop that returned True for 0 and False for 1 4) called the function - I'm still not clear when I should be doing this and when I shouldn't - some of the code in the tasks and videos have done it both ways in different situations and I'm not sure what determines its necessity.

even.py
def even_odd(number):
    number = int(5) % 2
    if number == 0:
        return True
    else: 
        return False

even_odd(5)

1 Answer

Todd Anderson
Todd Anderson
4,259 Points

Hi.

For this challenge you can pass your argument into a conditional instead of creating a new variable. Also in python you don't need to specify that a number is an int, it will figure that out when the code is run. Try this.

def even_odd(nums):
    if nums % 2 == 0:
        return True
    else:
        return False