Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
740 B
0
Indexable
Never
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()