how to perform operations on singly linked list in python