text: class Node:
      def __init__(self, data):
          self.data = data
          self.next = None
  
  
  class LList:
      def __init__(self):
          self.head = None
  
      def givehead(self):
          return self.head
  
      def printlist(self):
          temp = self.head
          while temp is not None:
              if temp.next is not None:
                  print(temp.data, end=" -->")
              else:
                  print(temp.data)
              temp = temp.prev
          print()
  
  
  def createfromlist(Arr):
      llist = LList()
      last = None
      for each in Arr:
          if llist.head is None:
              llist.head = Node(each)
              last = llist.head
          else:
              last.next = Node(each)
              last = last.next
      return llist
  
  
  """
  2.3 Delete Middle Node: Implement an algorithm to delete a node in the middle (i.e., any node but
  the first and last node, not necessarily the exact middle) of a singly linked list, given only access to
  that node.
  """
  
  
  def delmiddle(temp):
      while temp.next is not None:
          temp.data = temp.next.data
          temp = temp.next
          if temp.next.next is None:
              temp.next = None
  
  
  llist = createfromlist([1, 2, 3, 4, 5])
  llist.printlist()
  
  delmiddle(llist.head)
  
  llist.printlist()
  