This goes through the list of numbers only a single time, stopping early if possible. Could probably be code golfed further 😛
deffind_outlier(nums):odds=evens=0fornuminnums:is_even=num%2==0is_odd=notis_evenodds+=1ifis_oddelse0evens+=1ifis_evenelse0# Two of one kind prove the other kind is the outlier
if(odds>1andis_even)or(evens>1andis_odd):returnnum
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This goes through the list of numbers only a single time, stopping early if possible. Could probably be code golfed further 😛