input: Write a python function to append new data to the end of a linked list.
  assert linked_list_to_list(append_data([1, 2, 3], 4)) == [1, 2, 3, 4]
  assert linked_list_to_list(append_data([], 1)) == [1]
  assert linked_list_to_list(append_data([1], 2)) == [1, 2]
output: class ListNode:
      def __init__(self, val=0, next=None):
          self.val = val
          self.next = next
  
  def append_data(lst, data):
      def list_to_linked_list(lst):
          if not lst:
              return None
          head = ListNode(lst[0])
          current = head
          for val in lst[1:]:
              current.next = ListNode(val)
              current = current.next
          return head
  
      def linked_list_to_list(head):
          lst = []
          current = head
          while current:
              lst.append(current.val)
              current = current.next
          return lst
      
      head = list_to_linked_list(lst)
      new_node = ListNode(data)
      if head is None:
          return new_node
      current = head
      while current.next:
          current = current.next
      current.next = new_node
      return head