# Delete all even parity nodes from circular linked list in python

Python program for Delete all even parity nodes from circular linked list. Here problem description and explanation.

``````#  Python 3 program for
#  Remove all even parity nodes from a circular single linked list
def __init__(self, data) :
self.data = data
self.next = None

def __init__(self) :
self.tail = None

def insert(self, value) :
else :
self.tail.next = node

self.tail = node

#  Display node element of circular linked list
def display(self) :
else :
#  First node of linked list
print("", self.head.data, end = " ")
while (temp != None and temp != self.head) :
#  Display node value
print("", temp.data, end = " ")
#  Visit to next node
temp = temp.next

#  Handles the request to find set bits in given integer
def coutSetBit(self, num) :
result = num
result = result - ((result >> 1) & 1431655765)
result = (result & 858993459) + ((result >> 2) & 858993459)
result = (result + (result >> 4)) & 252645135
result = result + (result >> 8)
result = result + (result >> 16)
result = result & 63
return result

def removeNode(self) :
return

point = None
while (temp != None) :
if (self.coutSetBit(temp.data) % 2 == 0) :
auxiliary = temp
#  Visit to next node
temp = temp.next
if (auxiliary == self.tail) :
#  Removing a single node
self.tail = None
temp = None
else :
self.tail.next = temp

elif (auxiliary == self.tail) :
if (point != None) :
#  When Remove last node

self.tail = point
else :
if (point != None) :
#  When Remove last node
point.next = temp

auxiliary = None
else :
point = temp
#  Visit to next node
temp = temp.next
#  Stop the process
temp = None

def main() :
#  Insert node
cll.insert(3)
cll.insert(12)
cll.insert(32)
cll.insert(14)
cll.insert(27)
cll.insert(19)
cll.insert(1)
cll.insert(18)
print("\n Before Remove ", end = "")
cll.display()
#    Node  Binary     Even Parity
#     3     (11)         Yes
#    12     (1100)       Yes
#    32     (100000)     No
#    14     (1110)       No
#    27     (11011)      Yes
#    19     (10011)      No
#    1         (1)       No
#    18     (10010)      Yes
cll.removeNode()
print("\n\n After Remove", end = "")
cll.display()

if __name__ == "__main__": main()``````

Output

`````` Before Remove
3  12  32  14  27  19  1  18

After Remove