This is a question I have to do for a homework assignment. I understand most of it, and the function pretty much works except on one input and I don't know how to fix it.
Here is the code:
def alleven(nums):
if len(nums) == 0:
return True
else:
if nums[0] % 2 > 0:
return False
else:
return True
return alleven(nums[1:])
And then:
>>> alleven([0, 1, 0])
True
I think it's the 1 number that is not processing right, but I'm not entirely sure why?