Write a Python function to Find Element Occurring Odd Number of Times in a List


Topic: Write a Python function to Find Element Occurring Odd Number of Times in a List

Solution

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



List all Python Programs