geeksforgeeks python Linked List
class Node:
# Function to initialize the node object
def __init__(self, data):
self.data = data # Assign data
self.next = None # Initialize next as null
# Linked List class
class LinkedList:
# Function to initialize the Linked
# List object
def __init__(self):
self.head = None
# llist라는 Linked List 생성
llist = LinkedList()
# Linked List의 시작은 값이 1인 Node
llist.head = Node(1)
# 값이 각각 2와 3인 노드 생성
second = Node(2)
third = Node(3)
# Linked List의 시작에 second 노드 연결
llist.head.next = second
# second 노드에 third 연결
second.next = third
temp = llist.head
while(temp): #temp에 노드가 있는한
print(temp.data) #노드의 data 출력
temp = temp.next
# 1
# 2
# 3