I don’t know how to solve this. I don’t think I’ve learned anything that can detect whether or not something is a decimal or a whole number. I get the idea that it has to be divisible by 2, but I don’t know any further. Probably missing something obvious. Thanks for help!
The instructions are clear on what to do if it’s divisible/not divisible by 2. Did you read the instructions by any chance? Can you also post your code? That would help Thanks!
All right! Let’s get started.
Remember how an even number is a number that is divisible by 2?
Define a function is_even that will take a number x as input.
If x is even, then return True.
Otherwise, return False.
The modulo % operation is useful for determining if one number is divisible by another.
Make sure to return True instead of printing it!
I don’t see anything there that serves as a good hint. I tried this:
if x % 2 == True:
but I knew it wouldn’t work
Look at your
if statement, why check if it’s equal to a boolean? If we want to check if
x is fully divisible, we want our remainder from
x % 2 to be zero. Do you get the hint?
Also, make sure your code is indented properly
OH, ok, thank you! That makes sense.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.