class Node:

    def __init__(self, init_data, pointer = None):
        self.data = init_data
        self.pointer = pointer


    def get_data(self):
        return self.data


    def get_next(self):
        return self.pointer


    def set_data(self, data):
        self.data = data
    
    
    def set_next(self, data):
        self.pointer = data


class LinkedList:

    def __init__(self):
        self.root = None
        self.size = 0


    def get_size(self):
        return str(self.size)


    def add(self, data):
        new = Node(data, self.root)
        self.root = new
        self.size += 1


    def remove(self, data):
        current = self.root
        prev_node = None
        
        while current:

            if current.get_data() == data:
                if prev_node:
                    prev_node.set_next(current.get_next())
                else:
                    self.root = current
                self.size -= 1
                return

            else:
                prev_node = current
                current = current.get_next()

        print("Data not in linked list")          


    def search(self, data):
        current = self.root

        while current:
            if current.get_data == data:
                return data
            else:
                current = current.get_next()

        return None

class Node:

    def __init__(self, init_data, pointer = None):
        self.data = init_data
        self.pointer = pointer


    def get_data(self):
        return self.data


    def get_next(self):
        return self.pointer


    def set_data(self, data):
        self.data = data
    
    
    def set_next(self, data):
        self.pointer = data


class LinkedList:

    def __init__(self):
        self.root = None
        self.size = 0


    def get_size(self):
        return str(self.size)


    def add(self, data):
        new = Node(data, self.root)
        self.root = new
        self.size += 1


    def remove(self, data):
        current = self.root
        prev_node = None
        
        while current:

            if current.get_data() == data:
                if prev_node:
                    prev_node.set_next(current.get_next())
                else:
                    self.root = current
                self.size -= 1
                return

            else:
                prev_node = current
                current = current.get_next()

        print("Data not in linked list")          


    def search(self, data):
        current = self.root

        while current:
            if current.get_data == data:
                return data
            else:
                current = current.get_next()

        return None
