from linked_list import LinkedList # create a new linked list my_list = LinkedList() # add some nodes to the list my_list.add_to_head(4) my_list.add_to_head(2) my_list.add_to_head(1) # print the list print(my_list)
1 -> 2 -> 4 -> None
from linked_list import LinkedList # create a new linked list my_list = LinkedList() # add some nodes to the list my_list.add_to_head('b') my_list.add_to_head('a') # print the list print(my_list)
a -> b -> NoneIn both examples, we are using the `add_to_head` method provided by the `linked_list` package to add nodes to the head of the list.