Python basics, even or odd
Pretty sure my error is with trying to make number == float, but im not sure how to do it otherwise?
def even_odd (number): if number%2 == float: return False else: return True
Steven Parker195,705 Points
You could just test the remainder for 0. But you can make this one really compact if you recall that 0 is "falsey" and any other number is "truthy". So if you just return the opposite ("not") of the remainder:
def even_odd (number): return not number % 2
if number%2 == 0:
You want to replace float with 0. If a number is even, diving that number by two would have no remainder. e.g 4 % 2 = 0, since four is an even number.