• + 1 comment

    My code passes all test cases except 2nd, does anyone has this same issue? if not could please help?

    def deleteNode(llist, position): # Write your code here

    current = llist;
    
    if(current.next is not None):
        for i in range(position-1):
            if(current.next is not None):
                current = current.next;
    
        nodeToBeDeleted = current.next;
    
        if(nodeToBeDeleted.next is not None):
            current.next = nodeToBeDeleted.next;
            nodeToBeDeleted.next = None;
        else:
            current.next = None;    
    else:
        llist = None;
    
    return llist;