{"id":6920,"date":"2021-05-24T09:31:00","date_gmt":"2021-05-24T04:01:00","guid":{"rendered":"https:\/\/python-programs.com\/?p=6920"},"modified":"2021-11-22T18:39:26","modified_gmt":"2021-11-22T13:09:26","slug":"write-a-program-to-reverse-a-number-in-python","status":"publish","type":"post","link":"https:\/\/python-programs.com\/write-a-program-to-reverse-a-number-in-python\/","title":{"rendered":"Write a Program to Reverse a Number in Python | Reverse Digits or Integers"},"content":{"rendered":"

Given a number, thee task is to reverse the given number in Python.<\/p>\n

Examples:<\/h3>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

number=12345<\/pre>\n

Output:<\/strong><\/p>\n

The reversed number = 54321<\/pre>\n

Explanation:<\/strong><\/p>\n

After reversing the number we get 54321<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

number=7341<\/pre>\n

Output:<\/strong><\/p>\n

The reversed number = 1437<\/pre>\n

Example3:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

number=9840<\/pre>\n

Output:<\/strong><\/p>\n

The reversed number = 489<\/pre>\n

Explanation:<\/strong><\/p>\n

Here the reversed number is 0489 we neglect the leading zero so the reversed number is 489<\/pre>\n

Reverse the given Number in Python<\/h2>\n

There are several ways to reverse the given number in python some of them are:<\/p>\n