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 trialak37
2,344 PointsEven Odd Function
Can anyone please tell me why this code does not work?
Thanks!
def even_odd(number):
number = int(input("Enter a number and we will tell you if it is even or false"))
if number % 2 == 0:
return True
else:
return False
Krishna Pratap Chouhan
15,203 PointsHey Phillip, thanks.
Please try mentioning this as answer (rather than as comment) so that your answer could be accepted as best answer and the question can be closed.
Also, it helps the people trying to help on community portal as figuring out questions that have not been answered yet becomes easier.
Thanks once again for your help.
Phillip Kerman
Courses Plus Student 285 PointsPhillip Kerman
Courses Plus Student 285 PointsAs I understand the challenge, you need only write a function that accepts the number parameter. So, this part is not necessary:
number = int(input("Enter a number and we will tell you if it is even or false"))
(Plus, it is immediately overwriting whatever parameter is received for "number"
HTH