Robotics & Artificial Intelligence

Write a program to input a number and display the new number after reversing the digits.

Sample Input: 467

Sample Output: 764

Python Control Flow

3 Likes

Answer

n = int(input("Enter a number: "))
r = 0

while n > 0:
    d = n % 10
    r = r * 10 + d
    n = n // 10

print("Reversed number:", r)

Output

Enter a number: 467
Reversed number: 764

Answered By

2 Likes


Related Questions