# Python programming reverse number

Contents

## How to reverse a number in Python

In this program, we will learn to reverse the number of digits. In python, there is a simple way to reverse the number by using the reverse() function. To reverse any number we have to pass the number inside the reverse function as argument.

### Syntax:

reversed(variable)

### Example-1: Source Code

`#It will take user input value which will be consider as stringx = input('Enter your number or string to recerse: ')r = list(reversed(x))print("User input are:",x)print(f"Reversed value of {'x'} :",r)`

#### Output:

`C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.pyEnter your number or string to recerse: 12345User input are: 12345Reversed value of x : ['5', '4', '3', '2', '1']Process finished with exit code 0`

### Example-2: Source Cod

You can also reverse the value in two and one lines of code in python.

example -1:

Reverse the value in two lines of code in Python

`n='12345'print(list(reversed(n)))`
`C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py['5', '4', '3', '2', '1']Process finished with exit code 0`

Example -2:

Reverse the value in one line of code in python

`print(list(reversed('12345')))`
`C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py['5', '4', '3', '2', '1']Process finished with exit code 0`