Congratulations, you have implemented a tree in Python.
For review, in our implementation:
- Trees are a Python class called
TreeNodehas two properties,
- Nodes hold any type of data inside
childrenis a list, which can be empty or hold other instances of
- We add to
childrenby using the list method
- We remove from
childrenby filtering the list.
This implementation will come in handy for a variety of algorithms in the future. Excellent work and happy planting!