Python Python Basics Number Game App Even or Odd

gurinder singh
PRO
gurinder singh
Pro Student 723 Points

where is the error??

error??

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

2 Answers

Steven Parker
Steven Parker
94,464 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
PRO
AJ Salmon
Pro Student 4,496 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)
True

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 :)