# Find the Number Occurring Odd Number of Times using Lambda expression and reduce function in Python

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

In this article we are required to find that number from the list which occurs odd number of times in the given list. We are also required to use the Lambda function and the reduce function.

We design a function where the reduce function is used by applying the Lambda function to check if the element is present odd number of times.

## Example

Live Demo

from functools import reduce
def oddcount(i):
print(reduce(lambda x, y: x ^ y, i))
listA = [12,34,12,12,34]
print("Given list:\n",listA)
print("The element present odd number of times:")
oddcount(listA)

## Output

Running the above code gives us the following result −

Given list:
[12, 34, 12, 12, 34]
The element present odd number of times:
12