Reverse a Number in Python Using String Slicing

(Last Updated On: 28/12/2022)

Python Program to Reverse a Number Using String Slicing

# Reverse a Number in Python Using String Slicing

# we are taking a number from user as input
# entered value will be converted to int from string
 
num = int(input("Enter the number:"))
print(str(num)[::-1])

Output:

Enter the number:123456
654321

Leave a Reply

Your email address will not be published. Required fields are marked *