Showing wrong answer but my code is absolutely right.

Here is my code:

t = int(input())
for _ in range(t):
n = input()

Which Problem are you trying to solve?


If it’s this: Contest Page | CodeChef, then your solution gives the wrong output for the sample test input: the Online Judge compares your output with the expected output as strings, so your output must match the expected output exactly.

You can use lstrip() function to remove 0 from starting. Your code will print the reverse string because you are using string. You can also type cast into int so that automatically 0 from starting will be removed.

Personally I will not recommend to reverse number using this way.

t = int(input())
for _ in range(t):
    n = input()

Just a small suggestion, while posting your doubts, please specify which question you are asking for, otherwise its very difficult to answer. :slightly_smiling_face:
But from the structure of your code, I guess you are asking for Reverse the Number problem.
For that you can refer to my solution below:

t = int(input())
for tc in range(t):
    n = input()
    ans = ''
    for item in n:
        ans = item+ans

Note: If you do ans = ans+item in code, instead of ans = item+ans, then you would end up getting the same number that you have taken input. :slightly_smiling_face:
Don’t forget to convert the string into integer format at last. Your solution is all good, but its giving WA just because of this small thing.