Untitled
unknown
plain_text
3 years ago
740 B
3
Indexable
class node :
def __init__(self,data = None):
self.data = data
self.next = None
class linkedlist():
def __init__(self):
self.head = node()
def append(self,data):
new_node = node(data)
current = self.head
while current.next is not None:
current = current.next
current.next = new_node
def print_list(self):
getElement = []
current = self.head
while current.next is not None:
current = current.next
getElement.append(current.data)
print(getElement)
list = linkedlist()
list.print_list()
list.append(10)
list.append(10)
list.append(10)
list.append(10)
list.print_list()Editor is loading...