Can anyone debug this solution? Python 3


#1
    max_turns = 1
    mod = 1000000007
    for j in range(len(A)):
        n = len(A[j])
        #print(A[j])
        ans = 0
        if n<=1:
            ans = n
            max_turns = (max_turns*ans)//math.gcd(max_turns,ans)
            max_turns = max_turns%mod
            continue
        i = 1
        temp = A[j][i:n]+A[j][0:i]
        #print(temp,i)
        while temp!=A[j]:
            i+=1
            i = i%n
            temp = temp[i:n]+temp[0:i]
        #print(i,A[j])
        ans = i
        max_turns = (max_turns*ans)//math.gcd(max_turns,ans)
        max_turns = max_turns%mod
    return int(max_turns%mod)

Working fine for each string. Maybe there is some prblm with the LCM part of the solution.
Please Help.