Log in from a computer to take this course

You'll need to log in from a computer to start Learn Complex Data Structures. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
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

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?