TypeError: __str__ returned non-string (type tuple)
The code are follow
Hope some expert help why return this error where modified by diffrent ways to correct but still i got the same error
The error here in below codes return for me where trying like different return
The code are follow
from BTreeWordFinder import * from BalancedBTree import * class BalancedBTreeWordFinder(BTreeWordFinder): '' 'binary search class implemented with a balanced binary tree; inherits from BTreeWordFinder and thus takes advantage of its methods' '' def __init__(self, file, btree=None): '' 'Builder methods' '' BTreeWordFinder.__init__(self, file, btree) @staticmethod def main(): '' 'main method version of the class for the search engine implemented with a balanced tree' '' b = BalancedBTreeWordFinder(BalancedBTreeWordFinder.askFile(), BalancedBTree()) b.findOcurrencesInFile('dictionary.txt') b.viewIndex() b.showDepth() if __name__ == "__main__": BalancedBTreeWordFinder.main()The error line in class are follow
def __str__(self): return str(self._val) # here is the errorComplete exestuation of return error are follow
Error:Traceback (most recent call last):
File "D:/btree-word-finder-master/btree-word-finder-master/Code_and_texts/BalancedBTreeWordFinder.py", line 20, in <module>
BalancedBTreeWordFinder.main()
File "D:/btree-word-finder-master/btree-word-finder-master/Code_and_texts/BalancedBTreeWordFinder.py", line 16, in main
b.viewIndex()
File "D:\btree-word-finder-master\btree-word-finder-master\Code_and_texts\BTreeWordFinder.py", line 48, in viewIndex
self.getBTree().doinOrden()
File "D:\btree-word-finder-master\btree-word-finder-master\Code_and_texts\BTree.py", line 80, in doinOrden
self.inOrden(self.getRoot())
File "D:\btree-word-finder-master\btree-word-finder-master\Code_and_texts\BTree.py", line 89, in inOrden
self.visit(probe) # visit mean to search on traversed left
File "D:\btree-word-finder-master\btree-word-finder-master\Code_and_texts\BTree.py", line 107, in visit
print(node)
File "D:\btree-word-finder-master\btree-word-finder-master\Code_and_texts\Node.py", line 39, in __str__
return '%s %s %s'%(self._val)
TypeError: __str__ returned non-string (type tuple)
Hope some expert help why return this error where modified by diffrent ways to correct but still i got the same error
The error here in below codes return for me where trying like different return
str(sel._val) '%s %s %s'%(self._val) , return '{} {} {}'.format(self._val) and template = '{self._val}' return template.format(self) def __str__(self): return str(self._val) # here is the error
buran write Apr-12-2021, 01:55 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.