input: Write a python function to reverse a linked list.
  ```python
  assert printList(reverseLinkedList(createLinkedList([3, 5, 7, 8]))) == "8 7 5 3"
  assert printList(reverseLinkedList(createLinkedList([1, 2, 3, 4, 5]))) == "5 4 3 2 1"
  assert printList(reverseLinkedList(createLinkedList([10, 20, 30]))) == "30 20 10"
  
  class Node:
      def __init__(self, data):
          self.data = data
          self.next = None
  
  def createLinkedList(lst):
      if not lst:
          return None
      head = Node(lst[0])
      current = head
      for item in lst[1:]:
          current.next = Node(item)
          current = current.next
      return head
  
  def printList(head):
      result = []
      current = head
      while current:
          result.append(current.data)
          current = current.next
      return " ".join(map(str, result))
output: def reverseLinkedList(head):
      prev = None
      current = head
      while current:
          next_node = current.next
          current.next = prev
          prev = current
          current = next_node
      return prev