Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialgurinder singh
Courses Plus Student 1,422 Pointswhere is the error??
error??
def even_odd(num):
num = int(input("give me a num: "))
if num % 2 == 0:
return True
else:
return False
2 Answers
Steven Parker
231,268 PointsThe argument is passed in to the function, so you should not ask for input (the second line should not be there).
AJ Salmon
5,675 PointsYou 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 :)