del self __list[indexcount + return count this method is similar to the sortedlist remove(methodand is an extension of the list api it starts off by finding the index position where the first occurrence of the value belongs in the listand then loops as long as the index position is within the list and the item at the index position is the same as the given value the code is slightly subtle since at each iteration the matching item is deletedand as consequenceafter each deletion the item at the index position is the item that followed the deleted item def count(selfvalue)count index self __bisect_left(valuewhile (index len(self __listand self __list[index=value)index + count + return count this method returns the number of times the given value occurs in the list (which could be it uses very similar algorithm to sortedlist remove_ every()only here we must increment the index position in each iteration def index(selfvalue)index self __bisect_left(valueif index len(self __listand self __list[index=valuereturn index raise valueerror("{ index( ) not in listformatself __class__ __name__)since sortedlist is ordered we can use fast binary search to find (or not findthe value in the list def __delitem__(selfindex)del self __list[indexthe __delitem__(special method provides support for the del [nsyntaxwhere is sorted list and is an integer index position we don' test for an out-of-range index since if one is given the self __list[indexcall will raise an indexerror exceptionwhich is the behavior we want def __getitem__(selfindex)return self __list[indexthis method provides support for the [nsyntaxwhere is sorted list and is an integer index position