'Missing Arguments [closed]

---python

def insert_begining(self, data):
    nb = Node(data)
    nb.next = self.head
    self.head = nb

 def display(self):
     if self.head is None:
     print('The list is empty')
        else:
        temp = self.head
            while temp:
            print(temp.data, "-->", end = " " )
            temp = temp.next


L.insert_begining(23)

L.display()

Errors: missing 1 required positional argument: 'data'& missing 1 required positional argument: 'self'



Solution 1:[1]

The question should be explicit. What you have here, if I'm to guess, is that you copied some code from a class and didn't then put it into its own new class. Only functions that are members of a class require the 'self' parameter (which is handled automatically by the interpreter). Otherwise, self just becomes another parameter in your list that needs to be specified by the caller.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MichaelD