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

function argument from user input?

Hi everyone,

I've been struggling on this one, and would like to request for some insights. Can you kindly tell me what I'm doing wrong here:

def even_odd(numbr): usr_input = int(input("Please give me a number: ")) if (usr_input % 2 == 0): print("Thanks, you just gave me an EVEN number !") return True else: print("Thanks, you just gave me an ODD number !")

return False

Thanks in advance for any help you can provide. Regards, -Conrad

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

2 Answers

Stuart Wright
Stuart Wright
41,118 Points

The challenge asks you to pass a number to the function, and return True if that number is even or False if it is odd.

You have done something different. You have passed a number (which you have named 'numbr') to your function, but then you don't do anything with it. Instead you ask the user for a number, which you are not required to do.

So to fix your code, simply delete your user input line, and change your if statement to check if 'numbr' rather than 'usr_input' is odd/even.

Awesome ! It worked ! Thank you, Stuart, for your help.