Divisible by 2?
I don't understand what they mean by create a function that returns TRUE not divisible by 2?
Chris FreemanTreehouse Moderator 58,878 Points
There are two steps to returning a Boolean
- establish which value to return. For example
result = value > 5to find if value is greater than 5
- return the value. For example
These could also be combined using
return value > 5. The full python code would look similar to:
def greater_than_five(value): return value > 5
To find you if something is divisible by 2, you can check if there is no remainder from
value // 2 or use the modulo 2 syntax:
value % 2 which returns a 0 if it is divisible by 2. Be careful not to simply return the 0 result, as 0 is considered "False". Hint how can you turn the "False" value of 0 into a "Truthy" value?
Post back if you need more help. Good Luck!!