Learn about Reverse a Number in Python using Slicing in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Reverse a Number in Python using Slicing
# Python program to reverse a number using slicing # input from user num = int(input('Enter an integer number: ')) # calculate reverse of number reverse = int(str(num)[::-1]) # result print('The reverse number is = ', reverse)
Enter an integer number: 765
The reverse number is = 567
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Program to Reverse Integer using Recursion Python