I was doing Singly-Linked List implementation and I remember Linus Torvalds talking about it here.
In a singly-linked list in order to remove a node we should have access to the previous node and then change the node it is currently pointing to.
So any way we should have access to the previous node.
But Linus Torvalds removed the special case by using the idea of address in C. So that head also has the 'previous thing' which is the address of head which points to head. So he has used C's feature of pointer and address to remove special case.
The normal code with special case

The code with special case becoming normal case

I think this kind of special case removal in singly linked list cannot be done in python, because we don't have the concept of pointers (and hence I will not be able to go one step before head)? Am I right ?


Sure you can do this in Python. What he's saying is that you have some data structure that represents the list itself and points to the head of the list, and you manipulate that just as you would the pointer in a list item when you're dealing with the first list item.
Now Python is not C so the implementation would be different, but the principle applies. The list itself is not the same object as its first item, and list items should not have the same methods as the list as a whole, so it makes sense to use separate kinds of objects for them.
Both of them can, however, use an attribute of the same name (e.g.
next) to point to the next item. So when you iterate through the list, and you are at the first item, the "previous" item is the list itself, and you are manipulating itsnextattribute if you need to remove the first item.In the real world, of course, you would never write your own Python linked list class except as an exercise. The built-in
listis more efficient.