class ListNode: def __init__(self, x): self.val = x self.next = None if __name__ == '__main__': l1 = ListNode(1) l2 = l1 l1.next = ListNode(2) while l2: print(l2.val) l2 = l2.next
class ListNode: def __init__(self, x): self.val = x self.next = None if __name__ == '__main__': l1 = ListNode(1) l2 = l1 l1.next = ListNode(2) while l2: print(l2.val) l2 = l2.next