# 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