NumPy :
# Creating Node Class :
class Node:
def __init__(self, data, next = None):
self.data = data
self.next = next
# Creating LinkedList Class :
class LinkedList:
def __init__(self):
self.head = None
def __repr__(self):
node = self.head
nodes = []
while node is not None:
nodes.append(node.data)
node = node.next
nodes.append("None")
return " -> ".join(nodes)
# Creating Instance of LinkedList :
llist = LinkedList()
fNode = Node('a')
sNode = Node('b')
tNode = Node('c')
llist.head = fNode
fNode.next = sNode
sNode.next = tNode
tNode.next= Node('d')
print(type(llist))
print(llist)
# Output :
< class '__main__.LinkedList' >
a -> b -> c -> d -> None