Quick actions

cmd+k|ctrl+k

Navigation

Languages

Python linked list

Snippet info

Language

Python

Visibility

public

Author

rovanova

Created

2020-04-02T12:20:48Z

Updated

2020-04-02T12:22:17Z


class LinkedList():
    def __init__(self, value):
        self.head = { 
            "value": value,
            "next": None
        }
        self.tail = self.head
        self.length = 1
    
    def append(self, value):
        newValue = {
            "value": value,
            "next": None
        }
        self.tail['next'] = newValue
        self.tail = newValue
        
    
    def __str__(self):
        print("Head: ",self.head)
        print("Tail: ",self.tail)
        print("Length: ",self.length)
    
ll = LinkedList(10)
ll.append(5)
ll.append(6)
ll.append(7)
print(ll)
            
INFO