I have this function for linked lists in Python3:
def search_list(L: ListNode, key: int) -> ListNode:
while L and L.val != key:
L = L.next
return L
So my question is what is the difference between the above and:
def search_list(L: ListNode, key: int) -> ListNode:
while L != None and L.val != key:
L = L.next
return L
Is there a difference?
Is the first way of writing it is just saying: "while L is not NULL/None and L.val does not equal key, keep the loop running?"
Any help is appreciated, thanks.