r/pythonhelp • u/Flat_Fun_7488 • Mar 17 '22
hey guys im having some problems with b trees I have to implement the remove function but first of all I do not know if I am doing this ok
def remove(self, key):
if (self.root == self.isLeaf+1 and self.root == key):
self.root = None
return True
cur = self.root
while (cur != None):
if(cur == key and cur != self.root):
cur = cur + 1
keyIndex = remove(cur, key)
if(keyIndex is not -1):
if(cur == self.isLeaf):
remove(cur, keyIndex)
return true
tmpChild = remove(cur, keyIndex + 1)
tmpKey = BTreeGetMinKey(tmpChild)
remove(self, tmpKey)
BTreeKeySwap(self.root, key, tmpKey)
return true
cur = BTreeNextNode(cur, key)
return false
def __init__(self, orders, key=[], child=[], Leaf=True):
self.orders = orders
self.key = key
self.child = child
self.Leaf = Leafhere are some of my errors
File "/****/****/****/****/*****", line 109
if(keyIndex is not -1):
IndentationError: unexpected indent
thank you all
2
Upvotes
1
1
u/Goobyalus Mar 18 '22
Is this all inside a class? __init__ should be the initializer method of a class
1
u/Goobyalus Mar 18 '22
The one error that you posted is saying that the if statement is unexpectedly indented from the previous line: