Computer Science, asked by panther45, 8 months ago

Write a program to find reverse of given number using while loop in python​

Answers

Answered by tussipathak57
1

Reverse a number in Python | Python Program to Reverse a number

INPUT FORMAT: ...

OUTPUT FORMAT: ...

SAMPLE INPUT: 321.

SAMPLE OUTPUT: 123. ...

Step 1:Get input from the user.

Step 3:Check whether the given number is greater than zero using while loop.

Step 5:Multiply rev by 10 and add the remainder to it, store the answer in rev.

Pls mark me as brilliant answer and follow me

Answered by Oreki
1

number, reversedNumber = int(input("Enter a number to be reversed - ")), 0

while number > 0:

lastDigit = number % 10

reversedNumber = (reversedNumber * 10) + lastDigit

number //= 10

print("Reversed number -", reversedNumber)

Similar questions