Congratulations, you have created a doubly linked list class in Python!

We did this by:

  • Using our Node class to hold the value and links between nodes
  • Implementing a DoublyLinkedList class to handle external operations on the list, like adding and removing nodes
  • Creating an instance of our list, and using the .stringify_list() method to track the changes we made


Feel free to play around a bit with your code. Here are some ideas:

  • Create a few nodes and add them to both ends of a new doubly linked list
  • Remove your doubly linked list’s head or tail node
  • Print your list again — were the right nodes removed?
  • Remove a specific node from somewhere in the middle of the list, then print the list again. Did it work?
  • We created our .remove_by_value() method by iterating from the head of the list to the tail. Do you think you could start at the tail and iterate backward? Try it!

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?