Python链表创建function

设计四个function 要求如下

img

img

img

img

目前代码如下
class Node():

def __init__(self, data, next = None):
    self.data = data
    self.next = next

def __str__(self):
    return str(self.data)

class LinkedList():

def __init__(self):
    self.head = None

def prepend(self, data):
    node = Node(data, self.head)
    self.head = node

def append(self, data):

    current = self.head
    if current == None:
        node = Node(data, None)
        self.head = node
    else:
        while current != None:
            prev = current
            current = current.next
        
        node = Node(data, None)
        prev.next = node

def retrieve(self, index):
    counter = 0
    current = self.head
    while current != None and counter < index:
        current = current.next
        counter += 1
    return current.data
import copy

    def __str__(self):
        c = self.head
        s = ''
        while c:
            s += c.data + '-->'
            c = c.next
        else:
            s += 'None'
        return s
    def __len__(self):
        c = self.head
        n = 0
        while c:
            n += 1
            c = c.next
        
        return n 
    def pop(self):
        c = self.head
        if not c: return "None"
        c1 = c.next
        while c1:
            if c1.next == None:                
                c.next = None
                return c1
            else:
                c1 = c1.next
        return c1
    def pop_start(self):
        c = copy.copy(self.head)
        if not c: return "None"
        self.head.data = c.next.data
        self.head.next = c.next.next
        
        return c