Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def reverse_number(n):
- reversed_num = 0
- while n > 0:
- digit = n % 10
- reversed_num = reversed_num * 10 + digit
- n //= 10
- return reversed_num
- num = int(input("Enter a number: "))
- reversed_num = reverse_number(num)
- print("Reversed number:", reversed_num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement