Learn
We have a few zany characters to keep track of and Python nodes may do just the trick. Let’s get started…
Instructions
1.
Outside of Node
, instantiate three nodes. None have an argument for link_node
:
- the first has a value of
"likes to yak"
and be assigned to a variableyacko
- the second has a value of
"has a penchant for hoarding snacks"
and be assigned towacko
- the third has a value of
"enjoys spending time in movie lots"
and be assigned todot
2.
Now let’s give these nodes some responsibilities! yacko
can keep track of dot
and dot
can keep up with wacko
. wacko
can’t keep track of anything though.
Below the newly created nodes, use your .set_link_node()
method to give:
yacko
alink_node
ofdot
dot
alink_node
ofwacko
3.
Create two new variables, dots_data
, and wackos_data
. Use both getter methods to get dot
‘s value from yacko
and get wacko
‘s value from dot
. Print dots_data
and wackos_data
to the console to see the results!
When your code is passing, take a moment to consider:
- How would you get
yacko
‘s value? - How could you get from
yacko
towacko
‘svalue
? - How do you think nodes could be helpful for keeping track of and storing information?
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.