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

gurinder singh
gurinder singh
Pro Student 1,422 Points

where is the error??

def even_odd(num):
    num = int(input("give me a num: "))
    if num % 2 == 0:
        return True
        return False

2 Answers

Steven Parker
Steven Parker
119,813 Points

The argument is passed in to the function, so you should not ask for input (the second line should not be there).

AJ Salmon
AJ Salmon
5,663 Points

You don't need to use input for this one. The argument to the function will be a number, and it's passed to the function when it's called. For example, if I wanted to see if the number 20 was even or odd using our function, I would call it like this:

>>> even_odd(20)

It returns True because the number we put in the parentheses is even. When you're writing the function, you don't know what number will be passed to it, so you give it a placeholder. num is just a placeholder that represents future arguments to the function. All you need to do in this case is delete line two. Hopefully, this clears it up a bit! Happy coding :)