data_structures.linked_list.from_sequence

Recursive Program to create a Linked List from a sequence and print a string representation of it.

Classes

Node

Functions

make_linked_list(→ Node)

Creates a Linked List from the elements of the given sequence

Module Contents

class data_structures.linked_list.from_sequence.Node(data=None)
__repr__()

Returns a visual representation of the node and all its following nodes.

data = None
next = None
data_structures.linked_list.from_sequence.make_linked_list(elements_list: list | tuple) Node

Creates a Linked List from the elements of the given sequence (list/tuple) and returns the head of the Linked List.

>>> make_linked_list([])
Traceback (most recent call last):
    ...
ValueError: The Elements List is empty
>>> make_linked_list(())
Traceback (most recent call last):
    ...
ValueError: The Elements List is empty
>>> make_linked_list([1])
<1> ---> <END>
>>> make_linked_list((1,))
<1> ---> <END>
>>> make_linked_list([1, 3, 5, 32, 44, 12, 43])
<1> ---> <3> ---> <5> ---> <32> ---> <44> ---> <12> ---> <43> ---> <END>
>>> make_linked_list((1, 3, 5, 32, 44, 12, 43))
<1> ---> <3> ---> <5> ---> <32> ---> <44> ---> <12> ---> <43> ---> <END>