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 trialKurobe Kuro^T_T^
5,369 Pointswhat shoul i put in between the () it doesent say what to add
def is_odd(num):
if
2 Answers
Josh Keenan
20,315 PointsWhat you have between the () currently, num
, is perfectly fine.
Now you have to figure out if a number is odd, to check if a number is divisible by 2 you need to use the % operator. It checks if there is a remainder, so if there is a remainder we know it is an odd number.
Hope this helps, feel free to ask for help if needed, good luck!
Josh Keenan
20,315 PointsYou were close:
def is_odd(num):
if num % 2 != 0:
return True
Kurobe Kuro^T_T^
5,369 Pointsahhhh come on is wa a !=
Kurobe Kuro^T_T^
5,369 Pointsthank you for you time you a great person thank you for you time
Josh Keenan
20,315 Points!=
is the not equal to operator
Kurobe Kuro^T_T^
5,369 PointsKurobe Kuro^T_T^
5,369 Pointsbut how do i use the % im kind of connufuss
Josh Keenan
20,315 PointsJosh Keenan
20,315 PointsIf we wanted to know if a number was divisible by 3, it would look like this:
if num % 3 == 0:
This says, if the number is divisible by 3, then we can do whatever.
You want to check if it is NOT divisible by 2
Kurobe Kuro^T_T^
5,369 PointsKurobe Kuro^T_T^
5,369 Pointsohhh i get it now thanks i migth have a idea now
Josh Keenan
20,315 PointsJosh Keenan
20,315 PointsYou got this, I believe in you!
Kurobe Kuro^T_T^
5,369 PointsKurobe Kuro^T_T^
5,369 Pointsby the way should i make a variable for num???
Josh Keenan
20,315 PointsJosh Keenan
20,315 Pointsnum is already like a variable itself, you don't ever need to make a variable for a parameter, you can just use the parameter in the same way.
Kurobe Kuro^T_T^
5,369 PointsKurobe Kuro^T_T^
5,369 Pointsdef id_odd(num): if num % 4 == 2: answer = True elif num % 5 == 1: answer = False return answer
result = int(input("fagagaaga"))
i try is but it doesent work