n = int(input("Enter a number: "))
reversed_number = 0
while(n>0):
last_digit = n%10
reversed_number = reversed_number*10+last_digit
n = n//10
print("The reversed number is: ",reversed_number)- Take input from user and store in a variable called
n - Set the counter, which is
reverse_number= 0 - Check the
nis greater than0 - Get the last digit of entered number by using modulus operator(%)
- Store the last digit in
reversed_numbervariable - After storing the last digit,it should be removed.So remove the last digit by using
floor divisionoperator - Loop terminates when the value of
nis0 - Print the reversed number
N=124