class Node(object):
    def __init__(self,data = None, next_node = None):
        self.data = data
        self.next_node = next_node

class LinkedList:
    def __init__(self):
        self.head = None
        self.last_node  = None

    def print_ll(self):
        node = self.head
        ll_string = ""

        if node is None:
            print(None)

        while node :
            ll_string += str(node.data) + '->'
            node = node.next_node

        ll_string += 'None'
        print(ll_string)

    def insert_begining(self,data):
        if self.head is None:
            self.head = Node(data,None)
            self.last_node = self.head
        new_node = Node(data, self.head)
        self.head = new_node

    def insert_at_end(self,data):
        if self.head is None:
            self.insert_begining(data)

        if self.last_node is None:

            while node.next_node:
                node = node.next_node
    
            node.next_node= Node(data,None)
            self.last_node = node.next_node

        else:
            self.last_node.next_node=Node(data, None)
            self.last_node = self.last_node.next_node

    def to_list(self):
        arr =[]
        if self.head is None:
            return arr

        node = self.head
        while node:
            arr.append(node.data)
            node = node.next_node

        return arr
    
    def get_user_by_id(self,user_id):
        node = self.head
        while node:
            if node.data["id"]==int(user_id):
                return node.data
            node = node.next_node

        return None


        

