How to find odd or even element?

The program runs but does not pass all tests.
def find_outlier( integers):
for x in integers:
if x % 2 == 0:
print('%d' % x, x != 0)
return(x)

5a2d6b1536e25496271117.png
June 10th 19 at 16:23
2 answers
June 10th 19 at 16:25
You are given an array containing integers. The array consists entirely of integers even or odd numbers, except one number N. Write a method which accept array as argument and returns the number N.
It is not necessary to complete the question using the answer, just edit the question itself. - Donald_Carter73 commented on June 10th 19 at 16:28
June 10th 19 at 16:27
def find_outlier(integers):
 mask = [x % 2 for x in integers]
 sm = sum(mask)
 target = 0 if sm > 1 else 1
 idx = mask.index(target)
 return integers[idx]

Find more questions by tags Python