Help me in solving LINKLP problem

My issue

how to solve this

My code

def solve(head):

Learning course: Python with Data structures
Problem Link: Count loop length in Linked List Practice Problem in Python with Data structures - CodeChef