Once we calculate the midpoint using the len method, we’ll traverse the linked list until we reach the midpoint and then reorient the pointers to split the linked list. On line 2, we call our len method that we just implemented to calculate the length of the circular linked list object on which the method split_list is called and assign it to the variable size.
Next, we have if-conditions to handle two edge cases on lines 4-7. If size turns out to be 0, we return None, while if size is 1, we return self.head which is going to be the only node in the linked list. These two cases imply that no splitting can take place.
On line 9, we calculate the midpoint (mid) by dividing the length by 2 and flooring the answer using the // operator.
Now we are going to analyze the following code (lines 10-19):