Learn
Let’s start by defining our TreeNode
class. We’ll begin with having our node store a value, and additional functionality can be layered on in the following exercises.
Instructions
1.
Within script.py define an empty TreeNode
class.
2.
Inside the TreeNode
class, define an __init__()
method that takes self
and value
as parameters. Print “initializing node…” within __init__()
.
3.
Inside __init__()
, assign value
to self.value
.
4.
Nice work! Make an instance of TreeNode
and give it the value of your name as a string. Assign this to the variable: seed
.
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.