Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions data_structures/linked_list/from_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ def __repr__(self):


def make_linked_list(elements_list):
"""Creates a Linked List from the elements of the given sequence
(list/tuple) and returns the head of the Linked List."""
"""
Creates a Linked List from the elements of the given sequence
(list/tuple) and returns the head of the Linked List.
>>> list_data = [1, 3, 5, 32, 44, 12, 43]
>>> linked_list = make_linked_list(list_data)
>>> print(linked_list)
<1> ---> <3> ---> <5> ---> <32> ---> <44> ---> <12> ---> <43> ---> <END>
"""

# if elements_list is empty
if not elements_list:
Expand All @@ -34,11 +40,3 @@ def make_linked_list(elements_list):
current.next = Node(data)
current = current.next
return head


list_data = [1, 3, 5, 32, 44, 12, 43]
print(f"List: {list_data}")
print("Creating Linked List from List.")
linked_list = make_linked_list(list_data)
print("Linked List:")
print(linked_list)
2 changes: 1 addition & 1 deletion scripts/validate_filenames.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
import os

try:
Expand Down