Because the two objects are distinct instances. By default, python compare the memory adresses of objects.
To make it work, you need to implement a __eq__()
methods in TreeNode to redefine how to compare this objects.
More Related Contents:
- Discord Py on_message bot=False blocked?
- Python script to ping linux server
- TypeError: cannot parse from ‘list’
- how to check numbers in a list in python
- What are variable annotations?
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python 3
- How to print a string at a fixed width?
- FutureWarning: elementwise comparison failed; returning scalar, but in the future will perform elementwise comparison
- Convert bytes to int?
- How to read and write INI file with Python3?
- How to redirect stdout and stderr to logger in Python
- except-clause deletes local variable
- printing UTF-8 in Python 3 using Sublime Text 3
- How to specify “nullable” return type with type hints
- trying creating dropdown menu pygame, but got stuck
- Is it possible to make the keyboard module work with pygame and threading
- Meaning of end=” in the statement print(“\t”,end=”)? [duplicate]
- Does asyncio supports asynchronous I/O for file operations?
- Sending a password over SSH or SCP with subprocess.Popen
- Python: A program to find the LENGTH of the longest run in a given list?
- How to Open a file through python
- pandas.io.json.json_normalize with very nested json
- “This constructor takes no arguments” error in __init__
- multiprocessing vs multithreading vs asyncio
- AttributeError: ‘Client’ object has no attribute ‘send_message’ (Discord Bot)
- How to expire Django session in 5minutes?
- How does str.startswith really work?
- What is absolute import in python?
- What is the effect of using `python -m pip` instead of just `pip`? [duplicate]
- Printing subscript in python