Reverse The Number – CodeChef Solution

Hello coders, today we are going to solve Reverse The Number CodeChef Solution.

Reverse The Number - CodeChef Solution

Problem

Given an Integer N, write a program to reverse it.

Input

The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.

Output

For each test case, display the reverse of the given number N, in a new line.

Constraints

  • 1 <= T <= 1000
  • 1 <= N <= 1000000

Example

Input:

4
12345
31203
2123
2300

Output:

54321
30213
3212
32

Solution – Reverse The Number – CodeChef Solution

#Solution provided by CodingBroz
for _ in range(int(input())):
    N = int(input())
    Rev = 0
    while N > 0:
        Rev = Rev * 10 + N % 10
        N = N // 10
    print(Rev) 

Disclaimer: The above Problem (Reverse The Number) is generated by CodeChef but the Solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.

Leave a Comment

Your email address will not be published. Required fields are marked *