self head next node self head node elseself head node self tail node self head next self tail self size + deleting an element we may think that we can follow the same principle as for append and simply make sure the head points to the tail this would give us the following implementationdef delete(selfdata)current self tail prev self tail while currentif current data =dataif current =self tailself tail current next self head next self tail elseprev next current next self size - return prev current current current next as previouslythere is just single line that needs to change it is only when we remove the tail node that we need to make sure that the head node is updated to point to the new tail node howeverthere is serious problem with this code in the case of circular listwe cannot loop until current becomes nonesince that will never happen if you delete an existing nodeyou wouldn' see thisbut try deleting nonexistent node and you will get stuck in an indefinite loop