DEV Community

Discussion on: Daily Challenge #35 - Find the Outlier

Collapse
 
hectorpascual profile image
Héctor Pascual

Python :

def find_outlier(array):
    odd = [i for i in array if i%2 == 0]
    even = [i for i in array if i%2]

    if not even or not odd:
        return "ERROR"
    elif len(even) > len(odd):
        return odd[0]
    else:
        return even[0]