For this Question: You are given a string S (containing only lowercase characters). You need to print the repeated character whose first appearance is leftmost.The first line of input contains T denoting the number of testcases. T testcases follow. 
Each testcase contains one line of input containing the string S.

Constraints:
1 <= T <= 100
1 <= |S| <= 1000For each testcase, in a new line, print the character. If not found then print "-1".Input:
2
geeksforgeeks
abcd

Output:
g
-1

Explanation:
Testcase1: We see that both e and g repeat as we move from left to right. But the leftmost is g so we print g.
Testcase2: No character repeats so we print -1.
 , I have written this Solution Code: n=int(input())
while(n):
    n-=1
    string=input()
    temp=True
    for i in range(len(string)):
        if(string[i] in string[i+1:] and i!=len(string)-1):
            print(string[i])
            temp=False
            break
    if(temp):
        print(-1), In this Programming Language: Python, Now tell me if this Code is compilable or not?