data-structures-algorithms-python icon indicating copy to clipboard operation
data-structures-algorithms-python copied to clipboard

Why are we not getting an error if the item "figs" isn't even in the list?

Open whyevenquestion1t opened this issue 3 years ago • 1 comments

https://github.com/codebasics/data-structures-algorithms-python/blob/7d353b83e3498a0c1ec58ab184045b0b94f3a68b/data_structures/3_LinkedList/Solution/singly_linked_list_exercise.py#L129

whyevenquestion1t avatar Jan 07 '23 23:01 whyevenquestion1t

Because in the function remove_by_value(self,data), the function would return if data is found and deleted, or it would return when the while loop ends, i.e., we have reached the end of the linked-list without finding the desired data. So if "figs" isn't in the list, this function would return after it goes over the whole list. There would not be any error.

ROMEEZHOU avatar Mar 03 '23 15:03 ROMEEZHOU