Python
Implement function allEven() that takes a list of integers and returns True if all integers in the list are even, and False otherwise.
>>> allEven([8, 0, -2, 4, -6, 10])
True
>>> allEven([8, 0, -1, 4, -6, 10])
False
def allEven(a):
for one in a:
if one%2 == 1: # if odd, returning False
return False
return True
print(allEven([8, 0, -2, 4, -6, 10]))
print(allEven([8, 0, -1, 4, -6, 10]))
# Hit the thumbs up if you are fine with the answer. Happy Learning!
Get Answers For Free
Most questions answered within 1 hours.