Skip to content
Open
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
38 changes: 38 additions & 0 deletions Python/Queue/LinkedList.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class Node:


def __init__(self, data):
self.data = data # Assign data
self.next = None # Initialize next as null

class LinkedList:

# Function to initialize head
def __init__(self):
self.head = None

# This function prints contents of linked list
# starting from head
def printList(self):
temp = self.head
while (temp):
print(temp.data)
temp = temp.next


# Code execution
if __name__ == '__main__':

# Start with the empty list
llist = LinkedList()

llist.head = Node(1)
second = Node(2)
third = Node(3)

llist.head.next = second
# Link first node with second
second.next = third
# Link second node with the third node

llist.printList()