Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to traverse a linked list in python

# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next

while node:
	print(node.val) # access the values of the node by node.val
    node=node.next
# refer the below video https://www.youtube.com/watch?v=1YEBJfPf4vg
 
PREVIOUS NEXT
Tagged: #traverse #linked #list #python
ADD COMMENT
Topic
Name
7+3 =