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


class Linked:
    def __init__(self):
        self.head=None

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

    def print(self):
        if self.head is None:
            print("Linked list is empty")
            return
        itr = self.head
        llstr =''
        while itr:
            llstr +=str(itr.data)+'-->'
            itr = itr.next
        print(llstr)

    def insert_at_end(self,data):
        if self.head is None:
            self.head =Node(data,None)
            return
        itr = self.head
        while itr.next:
            itr = itr.next
        itr.next = Node(data,None)

    def get_length(self):
        count =0
        itr = self.head
        while itr:
            count +=1
            itr = itr.next
        return count


    def inseret_values(self,index,data):
        if index < 0 and index > self.get_length():
            raise Exception("Invalid Index")
        if index ==0:
            self.insert_at_begining(data)
            return
        count =0
        itr = self.head
        while itr:
            if count == index-1:
                node = Node(data,itr.next)
                itr.next =node
                break
            itr = itr.next
            count +=1

    def remove_at(self,index):
        if index < 0 and index > self.get_length():
            raise Exception("Invalid Index")
        if index == 0:
            self.head = self.head.next
            return
        count = 0
        itr = self.head
        while itr:
            if count == index - 1:
                itr.next = itr.next.next
                break
            itr = itr.next
            count += 1



if __name__ == '__main__':
    li=Linked()
    li.insert_at_end(46)
    li.insert_at_begining(23)
    li.insert_at_begining(24)
    li.insert_at_begining(100)
    li.insert_at_end(43)
    li.inseret_values(1,80)
    li.remove_at(2)
    li.print()


