Linked List Algorithm In Python