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

Laknath Gunathilake
Laknath Gunathilake
1,860 Points

can't seem to get the even_odd function to work

it says SyntaxError: print "True" when I run this code

even.py
def even_odd():
      if  8 % 2==0:
       print "True"  
      else:
        print "False" 
even_odd()

1 Answer

Steven Parker
Steven Parker
231,269 Points

Here's a few hints:

  • the challenge wants you to return the result, not print it
  • the True and False you will return are boolean(logical) values, not strings (so no quotes)
  • your function needs to take an argument
  • you will perform your test using the argument that is passed in
  • you don't need to call your function, just define it. The "check work" will call it and provide the argument(s)

Hopefully these will get you going!

Laknath Gunathilake
Laknath Gunathilake
1,860 Points
<p>def even_odd():
      number=int(input("enter number:"))
      if number%2==0:
           return True 
      else:
          return False </p>
          ```

it says TypeError: even_odd() takes 0 positional arguments but 1 was given