Add a new node with the given data to the beginning of the Linked List. Args: new_data (Any): The data to be added to the new node. Returns: None Examples: >>> linked_list = LinkedList() >>> linked_list.pu
(self, new_data: Any)
| 41 | return sum(1 for _ in self) |
| 42 | |
| 43 | def push(self, new_data: Any) -> None: |
| 44 | """ |
| 45 | Add a new node with the given data to the beginning of the Linked List. |
| 46 | |
| 47 | Args: |
| 48 | new_data (Any): The data to be added to the new node. |
| 49 | |
| 50 | Returns: |
| 51 | None |
| 52 | |
| 53 | Examples: |
| 54 | >>> linked_list = LinkedList() |
| 55 | >>> linked_list.push(5) |
| 56 | >>> linked_list.push(4) |
| 57 | >>> linked_list.push(3) |
| 58 | >>> linked_list.push(2) |
| 59 | >>> linked_list.push(1) |
| 60 | >>> list(linked_list) |
| 61 | [1, 2, 3, 4, 5] |
| 62 | """ |
| 63 | new_node = Node(new_data) |
| 64 | new_node.next_node = self.head |
| 65 | self.head = new_node |
| 66 | |
| 67 | def swap_nodes(self, node_data_1: Any, node_data_2: Any) -> None: |
| 68 | """ |