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 trial

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

it 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.

Gavin Ralston
Gavin Ralston
28,770 Points

If 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

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

5 Answers

Gavin Ralston
Gavin Ralston
28,770 Points

Your 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
Gavin Ralston
28,770 Points

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

it doesn't like that option either. I've used 'x', x, number, num1. also it just says "Try Again!"

Gavin Ralston
Gavin Ralston
28,770 Points

Added a comment to my previous answer. See if that helps.

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

Gavin Ralston
Gavin Ralston
28,770 Points

If 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.

it passed, it did't like the last line being all the way over to the left.

thank you!