def detect_loop(lst):
    ptr = lst.head
    while ptr != None and ptr.next != None and ptr.next != lst.head:
        ptr = ptr.next
    if ptr == None or ptr.next == None:
        return False
    if ptr.next == lst.head:
        return True

6ac78d411168e31a7bc6d1946bc0ce1b6ec9bfd9
<mask token>

def detect_loop(lst):
    ptr = lst.head
    while ptr != None and ptr.next != None and ptr.next != lst.head:
        ptr = ptr.next
    if ptr == None or ptr.next == None:
        return False
    if ptr.next == lst.head:
        return True
