So far we can:
Next up, we’ll define methods for our
LinkedList class that allow us to:
.insert_beginning() method which takes
new_value as an argument.
new_value. Name this
new_nodeto the existing
Note: Because the workspace is set up with spaces instead of tabs, you will need to use spaces to prevent Python from throwing an error. You can learn more about this here.
.stringify_list() method we can use to print out a string representation of a list’s nodes’ values.
The method should traverse the list, beginning at the head node, and collect each node’s value in a string. Once the end of the list has been reached, the method should return the string.
You can use
str() to convert integers to strings!
Be sure to add
"\n" between values so that each value prints on a new line.
Test your code by uncommenting the print statement at the bottom of script.py — did your list print what you expected?