Python solution of Linked List part