[Solved] Find a unique element in a list [closed]


You can use reduce (functools.reduce in Python3) if the integer is non-zero

>>> x = [False, False, False, 10, False, False]
>>> reduce(lambda i,j:i or j, x)
10

You can use a generator expression also here

>>> x = [False, False, False, 10, False, False]
>>> (i for i in x if i!=False).next()
10

Also check the package first

>>> from first import first
>>> first([False, False, False, 10, False, False])
10

2

solved Find a unique element in a list [closed]