mercredi 14 août 2019

Syntax error in if statement with multiple conditions in python

def __MaxHeapify(self,indx):
leftNodeIndex=self.__LeftNode(indx)
rightNodeIndex=self.__RightNode(indx)
largest=0

if leftNodeIndex< len(self.elementList) and 
 self.elementList[leftNodeIndex]>self.elementList[indx]:
   largest=leftNodeIndex
else:
   largest=indx;

if rightNodeIndex<len(self.elementList) and 
 self.elementList[rightNodeIndex]>self.elementList[self.largest]:
   largest=self.rightNodeIndex

if not largest==indx
   largest=0

I was trying to write Heap class in python to learn python. But I am facing syntax error in all 1st and last if conditions in above method. Kindly help me solve this as I find no issue in if condition with my eye.

Aucun commentaire:

Enregistrer un commentaire