Python Program to Find the Number Occurring Odd Number of Times in a List
def find_odd_occurring(alist):
"""Return the element that occurs odd number of times in alist.
alist is a list in which all elements except one element occurs an even
number of times.
"""
ans = 0
for element in alist:
ans ^= element
return ans
alist = input('Enter the list: ').split()
alist = [int(i) for i in alist]
ans = find_odd_occurring(alist)
print('The element that occurs odd number of times:', ans)
Output
Enter the list: 15 22 10 33 22 33 15 1 1 15 15
The element that occurs odd number of times: 10
