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 trialSpencer Heflin
7,389 PointsEven or Odd Code Challenge
I'm not sure what I'm doing wrong on this one, so any help would be awesome. I keep getting a syntax error for even_odd%2 when I'm trying to get the remainder. I feel like I'm on the right track, but I'm clearly messing something up. Thanks.
even_odd = random.randint()
if even_odd%2 = 0:
return True
else:
return False
2 Answers
AJ Salmon
5,675 PointsHi Spencer,
You need to be creating a function for this challenge. It should start like this:
def even_odd(num):
Then you can check if the number is even or odd inside the function, so that when it is called later on and passed an argument, it will return True if it's even and False if it's odd. You were on the right track with your if statement, and you will need to use an if/else block inside the function. Side note: you don't need to use random.randint() in this challenge, but if you did, you'd need to import the random library first. Happy coding!
Michael Gallego
1,568 PointsYou need a range for your randint argument. Forexample, randint(min, max)