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 trialbrianturner4
18,570 Pointsit does not like my code, please help
it just keeps saying try again but I'm not seeing the problem. Maybe I'm too sleepy.
brianturner4
18,570 Pointsdef even_odd(): if x % 2 == 0: return True return False
5 Answers
Gavin Ralston
28,770 PointsYour code works if you write it to accept an argument.
def even_odd(youre_just_missing_something_here_in_the_definition):
if x % 2 == 0:
return True
return False
Gavin Ralston
28,770 PointsTypeError: even_odd() takes 0 positional arguments but 1 was given
That means even_odd() is being called with a parameter. You'll want to put one in your function definition.
def even_odd(some_parameter):
In your case, you're working with "x" but you never defined it anywhere. I'm assuming you wanted "x" to be the parameter passed in to the function. :)
brianturner4
18,570 Pointsit doesn't like that option either. I've used 'x', x, number, num1. also it just says "Try Again!"
Gavin Ralston
28,770 PointsAdded a comment to my previous answer. See if that helps.
brianturner4
18,570 Pointsdef even_odd(number): if number %2 == 0: return True return False
Gavin Ralston
28,770 PointsIf that still isn't working, please submit your code in the post with the formatting tags around it. In Python, code blocks are defined with whitespace, not curly braces. If you're still getting a vague message about the code not passing, it might be the use of spaces.
brianturner4
18,570 Pointsit passed, it did't like the last line being all the way over to the left.
thank you!
Gavin Ralston
28,770 PointsGavin Ralston
28,770 PointsIf you can, copy and paste the code you're submitting in the challenge in a reply. Just surround it with three backticks ( the ` symbol) on both ends so it'll format properly.
Here's the quick breakdown on how to format your code